Script(s)

what I learn is what u c

Locking Cell and Changing Cell Style UltraWebGrid

with 6 comments

Refer this article for Column Locking / Freezing in Infragistics Ultra WebGrid

If you need to change background color for a  frozen columns then ..
backcolor property must be changed first then cells have to be locked.

  e.Layout.Bands(0).Columns(0).CellStyle.BackColor = Drawing.Color.Beige
  e.Layout.Bands(0).Columns(0).Header.Fixed = True

and in InitializeLayout of ultraWebgrid

Private Sub ultrawebgrid_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles uwgCategory.InitializeLayout

e.Layout.UseFixedHeaders = True

End Sub 

 

 

 

Written by gchandra

October 2, 2007 at 11:07 am

Comment on Server Side Asp.Net

with 2 comments

Inspired by ASP.NET 2.0 Server Side Comments

If you want to comment a particular column in GridView, HTML commenting approach wont work.

You have to use

<%--

--%>

example:

<asp:GridView ID="gvSample" runat="server" AutoGenerateColumns="False"
GridLines="None" CellPadding="0" CellSpacing="0">
<Columns>
<asp:BoundField DataField="Column1" ItemStyle-Width="25px" />
<asp:BoundField DataField="Column2" ItemStyle-Width="15px" />
<asp:BoundField DataField="Column3" ItemStyle-Width="15px" />

<%-- Commented Column --%>
&lt;%-- <asp:BoundField DataField="Column4" ItemStyle-Width="15px" />--%>

</Columns>
</asp:GridView>

Written by gchandra

October 2, 2007 at 9:53 am

Vista seems to be slower ?

leave a comment »

With all the dual core processors and 1+ GB RAM Microsoft VISTA didn’t perform as expected.

Later I found out the default power setting in the “Power Saver” plan limits the CPU to 50 percent.

To improve the speed

Open the Power Options from Control panel and change it to “High Performance” to give it full throttle.

Vista Power Plan

Written by gchandra

September 28, 2007 at 10:18 am

Posted in Tips and Tricks, Vista

Tagged with , ,

Call Javascript Function inside asp:Hyperlink Control

with 8 comments

If you ever want to call a javascript function (with or without  parameter) from a server side hyperlink control here it is..

Step 1 :

declare your javascript function between

Step 2:

<asp:HyperLink ID=”hypCate” runat=”server”

NavigateUrl='<%# “javascript:showPopUp(” & DataBinder.Eval(Container.DataItem, “ID”) & “);” %>’

Text='<%#DataBinder.Eval(Container.DataItem, “Name”)%>’ />

Carefully follow the single and double quotes for NavigateUrl attribute.

Needless to say showPopUp is the name of Javascript Function.

It displays the NAME as hyperlink. Clicking that calls javascript showPopUp.

Written by gchandra

September 27, 2007 at 4:55 pm

Column Locking / Freezing in Infragistics Ultra WebGrid

with 10 comments

(NetAdvantage for ASP.NET)

If you want to freeze first few columns like EXCEL and horizontally scroll rest of the columns in Ultra WebGrid here you go…

Event :

UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)

VB Code :

e.Layout.UseFixedHeaders = true
e.Layout.Bands(0).Columns(1).Header.Fixed = true
e.Layout.Bands(0).Columns(2).Header.Fixed = true

Above code freezes the  two columns (second,third) in Grid.

C# Code

protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
{

e.Layout.UseFixedHeaders = true;
e.Layout.Bands[0].Columns[1].Header.Fixed = true;
e.Layout.Bands[0].Columns[2].Header.Fixed = true;

}

Written by gchandra

September 26, 2007 at 8:04 pm

Gridview : Empty First Row / Asp.net 2.0

leave a comment »

If you using Gridview control and your Grid doesnt have HEADER information then make sure you turn off the “ShowHeader” property for that Gridview or else you will notice a blank line on top of the grid.  If you are

If you do viewsource you will notice this mystery line <tr><th></th</tr> as first line of grid table.

Written by gchandra

September 26, 2007 at 8:32 am

Posted in Asp.Net

Tagged with ,

GridView Sorting/Paging w/o a DataSourceControl DataSource (VB.NET)

with 20 comments

This page is reproduced from this URL. Copied here for easy reference. All credits to the original author.
                                                                             ______________________

If you set AllowPaging=”true” or AllowSorting=”true” on a GridView control without using a DataSourceControl DataSource (i.e. SqlDataSource, ObjectDataSource), you will run into the following errors:

When changing the page on the GridView control:

The GridView ‘GridViewID’ fired event PageIndexChanging which wasn’t handled.

When clicking a column name to sort the column on the GridView control:

The GridView ‘GridViewID’ fired event Sorting which wasn’t handled.

As a result of not setting the DataSourceID property of the GridView to a DataSourceControl DataSource, you have to add event handlers for sorting and paging.

<%@ Page Language=”VB” %>

 

<%@ Import Namespace=”System.Data” %>

<%@ Import Namespace=”System.Data.OleDb” %>

 

<script runat=”server”>   

    Private Sub PopulatePublishersGridView()

        Dim connectionString As String = AccessConnectionString()

        Dim accessConnection As OleDbConnection = New OleDbConnection(connectionString)

 

        Dim sqlQuery As String = “SELECT [PubID], [Name], [Company Name], [Address], [City], [State], [Zip], [Telephone], [Fax], [Comments] FROM Publishers ORDER BY [Name] ASC;”

 

        Dim accessCommand As New OleDbCommand(sqlQuery, accessConnection)

 

        Dim publishersDataAdapter As New OleDbDataAdapter(accessCommand)

        Dim publishersDataTable As New DataTable(“Publishers”)

        publishersDataAdapter.Fill(publishersDataTable)

 

        Dim dataTableRowCount As Integer = publishersDataTable.Rows.Count

 

        If dataTableRowCount > 0 Then

            gridViewPublishers.DataSource = publishersDataTable

            gridViewPublishers.DataBind()

        End If

    End Sub

 

    Private Function AccessConnectionString() As String

        Dim accessDatabasePath As String = Server.MapPath(“~/App_Data/biblio.mdb”)

        Return String.Format(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};”, accessDatabasePath)

    End Function

 

    Private Property GridViewSortDirection() As String

        Get

            Return IIf(ViewState(“SortDirection”) = Nothing, “ASC”, ViewState(“SortDirection”))

        End Get

        Set(ByVal value As String)

            ViewState(“SortDirection”) = value

        End Set

    End Property

 

    Private Property GridViewSortExpression() As String

        Get

            Return IIf(ViewState(“SortExpression”) = Nothing, String.Empty, ViewState(“SortExpression”))

        End Get

        Set(ByVal value As String)

            ViewState(“SortExpression”) = value

        End Set

    End Property

 

    Private Function GetSortDirection() As String

        Select Case GridViewSortDirection

            Case “ASC”

                GridViewSortDirection = “DESC”

 

            Case “DESC”

                GridViewSortDirection = “ASC”

        End Select

 

        Return GridViewSortDirection

    End Function

 

    Protected Sub gridViewPublishers_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)

        gridViewPublishers.DataSource = SortDataTable(CType(gridViewPublishers.DataSource,DataTable), True)  gridViewPublishers.PageIndex = e.NewPageIndex

        gridViewPublishers.DataBind()

    End Sub

 

    Protected Function SortDataTable(ByVal pdataTable As DataTable, ByVal isPageIndexChanging As Boolean) As DataView

        If Not pdataTable Is Nothing Then

            Dim pdataView As New DataView(pdataTable)

            If GridViewSortExpression <> String.Empty Then

                If isPageIndexChanging Then

                    pdataView.Sort = String.Format(“{0} {1}”, GridViewSortExpression, GridViewSortDirection)

                Else

                    pdataView.Sort = String.Format(“{0} {1}”, GridViewSortExpression, GetSortDirection())

                End If

            End If

            Return pdataView

        Else

            Return New DataView()

        End If

    End Function

 

    Protected Sub gridViewPublishers_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)

        GridViewSortExpression = e.SortExpression

        Dim pageIndex As Integer = gridViewPublishers.PageIndex

        gridViewPublishers.DataSource =  SortDataTable(CType(gridViewPublishers.DataSource,DataTable), False)

        gridViewPublishers.DataBind()

        gridViewPublishers.PageIndex = pageIndex

    End Sub

 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        PopulatePublishersGridView()

    End Sub

</script>

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head id=”Head1″ runat=”server”>

    <title>GridView Sorting/Paging without a DataSourceControl DataSource</title>

</head>

<body>

    <form id=”form” runat=”server”>

        <div>

            <asp:GridView ID=”gridViewPublishers” AllowPaging=”true” AllowSorting=”true” AutoGenerateColumns=”false”

                EmptyDataText=”No records found” PagerSettings-Mode=”NumericFirstLast” PageSize=”25″

                OnPageIndexChanging=”gridViewPublishers_PageIndexChanging” OnSorting=”gridViewPublishers_Sorting”

                runat=”server”>

                <AlternatingRowStyle BackColor=”LightGray” />

                <HeaderStyle BackColor=”Gray” Font-Bold=”true” Font-Names=”Verdana” Font-Size=”Small” />

                <PagerStyle BackColor=”DarkGray” Font-Names=”Verdana” Font-Size=”Small” />

                <RowStyle Font-Names=”Verdana” Font-Size=”Small” />

                <Columns>

                    <asp:BoundField DataField=”PubID” HeaderText=”Publisher ID” SortExpression=”PubID” />

                    <asp:BoundField DataField=”Name” HeaderText=”Name” SortExpression=”Name” />

                    <asp:BoundField DataField=”Company Name” HeaderText=”Company Name” SortExpression=”Company Name” />

                    <asp:BoundField DataField=”Address” HeaderText=”Address” SortExpression=”Address” />

                    <asp:BoundField DataField=”City” HeaderText=”City” SortExpression=”City” />

                    <asp:BoundField DataField=”State” HeaderText=”State” SortExpression=”State” />

                    <asp:BoundField DataField=”Zip” HeaderText=”Zip” SortExpression=”Zip” />

                    <asp:BoundField DataField=”Telephone” HeaderText=”Telephone” SortExpression=”Telephone” />

                    <asp:BoundField DataField=”Fax” HeaderText=”Fax” SortExpression=”Fax” />

                    <asp:BoundField DataField=”Comments” HeaderText=”Comments” SortExpression=”Comments” />

                </Columns>

            </asp:GridView>

        </div>

    </form>

</body>

</html>

Written by gchandra

September 25, 2007 at 2:02 pm

Posted in Web Coding

How to change news channel of your choice in Visual Studio .Net Start Page

with one comment

Close Visual Studio if its open.

If you are an Advanced User who has priviledges to edit Registry here you go.

Start > Run > RegEdit

(Backup registry before making changes)

GOTO

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\StartPage

On the Right Panel right click on  NewsChannel and select modify

Replace this (http://msdn.microsoft.com/sql/rss.xml) RSS feed with any valid RSS feed of your choice.

Close Registry.

Happy Programming  🙂

Written by gchandra

September 19, 2007 at 9:06 am

Posted in Visual Studio

How to Clear Recent Project list or File list from Visual Studio .Net Start Page

with one comment

If you are an Advanced User who has priviledges to edit Registry here you go.

Method 1:

          Close Visual Studio (if its open)

Start > Run > RegEdit

(Backup registry before making changes)

GOTO

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\ProjectMRUList

remove unnecessary items from list.

If needed reorder your list.  File1, File2 etc. Otherwise Visual Studio might not read them properly.

Similarly repeat the steps for FileMRuList

Method 2:

If you can’t edit registry or not feeling comfortable here is an alternate method.

http://www.codeproject.com/csharp/VSRecentcleaner.asp

Happy Programming 🙂 

Written by gchandra

September 19, 2007 at 8:58 am

Posted in Visual Studio

Create/Manage Multiple Websites in IIS on Windows 2000 / XP

leave a comment »

On Windows 2000/XP Professional only one website can be created in IIS. (i.e) default website.

If you have some requirement for testing multiple websites on same development box its not possible with IIS alone.

FREE IIS Management tool

JetStat has a tool to accomplish the above mentioned task. “IISAdmin”

IISAdmin 

It has some cool features like

– Create and Manage as many local IIS web sites.
– Install and configure asp scripts on local web sites
– Gives quick access to home folder of the website
– Enabling advanced features on creation of new web site
– Quick access to IIS Management Console
– Automatically configures database folder permissions
– Full support Windows 2000/XP (IIS 5.0, 5.1, 6.0)
– Easy of use and flexible

The application is FREE and it doesn’t occupy much space.

Download from here.

Written by gchandra

September 4, 2007 at 11:29 pm

Asp.net Get/Set Date and Time as String

with one comment

In many occasions all we may need is simple date and time.

Now property gives more information which needs to be trimmed down using Format function. Here we have two handy string type properties from Microsoft.

TimeString Property

Returns or sets a String value representing the current time of day according to your system.

TimeString always returns the system time as “HH:mm:ss“, which is a 24-hour format. This format is culture-invariant, which means it does not change even if you change the Regional Options in Control Panel.

ex :

Dim MyTime As String = TimeString

If CInt(TimeString.Substring(0, 2)) &lt; 12 Then
MyGreeting = Reverse("Good Morning")
Else
MyGreeting = Reverse("Good Afternoon")
End If

Timeofday : returns / sets the same but as date datatype.

ooOoo

DateString Property

DateString always returns the system date as “MM-dd-yyyy“, which uses the abbreviated month name.

These formats are culture-invariant, which means they do not change even if you change the Regional Options in Control Panel.

Today : returns / sets the same but as date datatype.

kick it on DotNetKicks.com

Written by gchandra

September 4, 2007 at 10:26 am

Posted in Asp.Net

XP to Vista migration.

leave a comment »

If you are a developer / power user who uses 2000 / XP professional  you need to upgrade to Vista Ultimate.

Even though Vista Home Premium has IIS it doesn’t support (or features enabled) in home premium edition.

For ex: If you want to see Local User Groups  (Admin tools, Comp mgt) you can not see that in Home Premium. Its available in Ultimate edition.

Written by gchandra

September 3, 2007 at 10:51 pm

Posted in Tips and Tricks, Vista

How to Enable Administrator Account in Vista Home Premium ?

with 28 comments

Restart your PC in Safe Mode with Networking from boot menu (press f8 when compter starts)

Log onto personal account with admin access.

goto command prompt (start > run > cmd)

type

net user administrator /active

This should enable admin account.



Written by gchandra

September 3, 2007 at 10:45 pm

Posted in Tips and Tricks, Vista

Interface vs Base Class (.Net)

leave a comment »

Interface is similar to a base class, it is also very different.

They are similar..

– Both provide structure to another class that uses them

– Both can be used for polymorphism
Interfaces are different than base classes ..

– A class can inherit only one base class, but it can implement many interfaces. (Very important)

– A base class can contain implementation, an interface cannot contain implementation

– Interfaces can only contain Methods, Properties, Indexers, and Events. They cannot contain fields or constants (which are used for implementation)

Written by gchandra

August 29, 2007 at 4:40 pm

Posted in Asp.Net, Interview Qn

Steps to Change from Visual Studio Development Server to Use IIS Web Server

with 5 comments

Using Visual Studio 2005

 1. Goto Project Properties > Select Web Tab

2. Click “Use IIS Web Server” radio button

3. Click on “Create Virtual Directory” button

4. Open Web.config and change debug to true  <compilation debug=”true”>

5. Open IIS (Start > Run > Inetmgr)

6. Goto that your project Virtual Directory

7. Right click > Select Properties

8. Under Virutal Directory Tab, make sure it has Application Name.  If its blank, click on Remove button next to it and click Create.

9. Under ASP.Net tab make sure Asp.net Version is 2.0 or whatever you need

10. Under Directory Security tab click EDIT

11. Make sure Anonymous and Integrated Windows authentication is enabled.
If these steps are not followed

you may not be able to debug you application using Visual Studio,

you may not be able to use IIS web server or its features.

Written by gchandra

August 29, 2007 at 11:24 am

Asp.net Detecting Session timeout and redirection

leave a comment »

If you are using Basepage logic its better to use this code there.

Redirection logic is written for pages with Frames or without Frames


Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) MyBase.OnPreRender(e)
If context.Session.IsNewSession = True Then
Dim strCookieHeader As String = Page.Request.Headers("Cookie")
If Not strCookieHeader Is Nothing Then
strCookieHeader = strCookieHeader.ToLower
End If

'Checking for duplicate Session.
If Not strCookieHeader Is Nothing AndAlso strCookieHeader.IndexOf("asp.net_sessionid") >= 0 Then
If Page.Request.IsAuthenticated = True Then
System.Web.Security.FormsAuthentication.SignOut()
End If

'If you want to redirect to defaultpage you can use this
'Page.Response.Redirect("default.aspx?Timeout")

'If you are using Frames then this will work.
Response.Write("window.open('default.aspx?Timeout','_parent');")
End If
End If
End Sub

Written by gchandra

August 28, 2007 at 10:12 am

Posted in Asp.Net

Must have tools for Web Developer – 2

leave a comment »

Previous article : Must have tools for Web Developer – 1

IEDeveloper Toolbar

This is excellent application for web developers & designers. Not only on the pages you design, it can used on any website to learn about it or make fun of it in cafeteria.

You can see how your page looks on different resolution without changing your display setting.

Following lines are from Microsoft, which is what I also wanted to write.

– Explore and modify the document object model (DOM) of a Web page.

– Locate and select specific elements on a Web page through a variety of techniques.

– Selectively disable Internet Explorer settings.

– View HTML object class names, ID’s, and details such as link paths, tab index values, and access keys.

– Outline tables, table cells, images, or selected tags.

– Validate HTML, CSS, WAI, and RSS web feed links.

– Display image dimensions, file sizes, path information, and alternate (ALT) text.

– Immediately resize the browser window to a new resolution.

– Selectively clear the browser cache and saved cookies. Choose from all objects or those associated with a given domain.

– Display a fully featured design ruler to help accurately align and measure objects on your pages.

– Find the style rules used to set specific style values on an element.

– View the formatted and syntax colored source of HTML and CSS.
Click here to Download

http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en

Cost: Free

ooOoo

Written by gchandra

August 17, 2007 at 9:29 am

Posted in Web Coding

Developers PC – What should it have ? How it should be ?

leave a comment »

These are the optimized settings I found and use for my PC running with xp & vista. (You have the right to disagree with me 100%)

– Switch start menu to classic mode. No jazzy menus, so no delay in loading menu .

– Keep desktop background plain and simple. I prefer using black background so that the icons stand out.

– Enable Quick Launch in taskbar.

– Add NOTEPAD & frequently used application shortcuts in quick launch.

– Pay attention to Windows Update & Windows defender scanning. If it prompts update it. Its good practice to keep your system smooth. (Unless you have restriction not to update)

BROWSER Setting

– My work expects me to use IE (which is great ofcourse), keep blank page as startup page.

– Customize the icons and remove the unwanted ones like EDIT, PRINT, MAIL and so on.

– Keep small icons instead of Large icons.

– Organize your favourites menu. Create folders and sub folders under LINKS and move frequently used items under it. It helps me a lot.

– Install Google Toolbar. It helps in better search. Once you start typing, it prompts with previously done searches. (I love this feature)

– Uninstall any unwanted toolbars (i hate the bulky Yahoo & MSN toolbars).
What can you do to improve your efficiency ?

Use both your hands (not just index finger) while typing and selecting menus.

Use mouse to the minimum. (unless you are using some graphical software or doing some audio/video editing)

Use shortcuts as much as you can. (click here to see list of windows shortcuts)

(more to come..)

Written by gchandra

August 9, 2007 at 8:11 pm

Posted in Tips and Tricks

Must have tools for Web Developer – 1

with 2 comments

Pixie

This is a great tool for webmasters / web designers / web developers. Small, Light application sits on your System Tray.

It’s very useful if you want to find the color code of anything that’s seen on your PC monitor.Nattyware has given this application FREE of cost. Great job!

I have been using this for more than 2 years and it never had any problems.

Knock Knock !!

For more info and download

http://www.nattyware.com/pixie.html

Cost: Free

ooOoo

Cropper

This is another great tool for Screen capture. No Alt + Print Screen then copying to word or Photoshop.

Open the application, resize the area you can to capture and double click. The output is saved as PNG / JPG / Bmp or even redirected to Printer.

This application is also a light and is always available on your Tray until you click exit.

For more info and download

http://blogs.geekdojo.net/brian/articles/Cropper.aspx

Cost: Free

ooOoo

JRuler

Want to measure you screen from left to right or top to bottom ?

Here comes JRuler (free ruler).

It supports various units of measurement like pixels, cms, inches and so on.

Want to measure the screen across (bottom left to top right) it can be done but you need to buy Professional (it’s not that expensive for the functionality it offers.)

For more info and download

http://www.spadixbd.com/freetools/jruler.htm

Cost: Free

ooOoo

Written by gchandra

July 25, 2007 at 3:14 pm

Posted in Tools

Stop the Search (Visual Studio 2003)

leave a comment »

Search on all folders

When using Visual Studio, there are times you need to search entire project or solution.

The short cut for this search is CTRL + Shift + F
Stop the Search

If you are lucky enough, the page you are looking for will appear first. If you want to STOP rest of the search
press CTRL + Shift + F again.

It will show the STOP button instead of SEARCH button.

Click STOP.

Written by gchandra

March 29, 2007 at 5:01 pm