About the author

Vijay Kodali
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Check if variable is number in C#

            string s ="45";
            int i;
            bool isNum = int.TryParse(s.ToString(), out i); 
 
            if (isNum)
                Response.Write(i); //integer 
            else
                Response.Write("Not an interger");

Categories: ASP.NET | C#
Posted by vijay on Thursday, June 18, 2009 9:27 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Great tool for LINQ -LINQPAD

you could test a LINQ query without pressing F5 in Visual Studio..

http://www.linqpad.net/

 the tool also includes all the samples from the book "C# 3.0 in a Nutshell" written by Joseph Albahari


Categories: C# | LINQ
Posted by vijay on Wednesday, March 12, 2008 10:18 AM
Permalink | Comments (1) | Post RSSRSS comment feed

Lambda Expressions

A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.Lambda Expressions provide a more concise, functional syntax for writing anonymous methods.

Categories: .Net 3.5 | C# | LINQ
Posted by vijay on Tuesday, January 22, 2008 8:43 PM
Permalink | Comments (0) | Post RSSRSS comment feed

ListView

One of the new controls in ASP.NET 3.5 is ListView. It resembles the GridView control, except that it displays data by using user-defined templates instead of row fields.

The ListView control supports the following features:

ü  Support for binding to data source controls such as SqlDataSource, LinqDataSource, and ObjectDataSource.

ü  Customizable appearance through user-defined templates and styles.

ü  Built-in sorting capabilities.

ü  Built-in update and delete capabilities.

ü  Built-in insert capabilities.

ü  Support for paging capabilities by using a DataPager control.

ü  Built-in item selection capabilities.

ü  Programmatic access to the ListView object model to dynamically set properties, handle events, and so on.

ü  Multiple key fields.

 


Categories: .Net 3.5 | ASP.Net 3.5 | C#
Posted by vijay on Monday, January 14, 2008 8:13 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Click event for Listbox

In Asp.Net ListBox, there are no events for Click action. The follwing code is useful in this regard..

 

[code:c#]

protected void Page_Load(object sender, EventArgs e)

{

if (Request["__EVENTARGUMENT"] != null && Request["__EVENTARGUMENT"] == "submit")    {       

//your code for click action

                                                      }

ListBoxNames.Attributes.Add("ondblclick", ClientScript.GetPostBackEventReference(ListBoxNames, "submit"));

}

[/code]


Categories: ASP.NET | C#
Posted by vijay on Wednesday, September 12, 2007 12:57 PM
Permalink | Comments (2) | Post RSSRSS comment feed

to call server side function from Javascript function?

Some times we need to call server side function from Javascript function.For example,callig a PoupWindow(with value from code behind) on HyperLink click. 

This must be implemented by creating a additional request to the web server and that’s the only way to invoke methods on the server. Page methods are used for this.

What is PageMethod?

A PageMethod is a public static method that is exposed in the code-behind of a page and can be called from the client script. PageMethods are annotated with [System.Web.Services.WebMethod] attribute.

The code is simple..

Server side function

[code:c#]

[System.Web.Services.WebMethod] public static void Score(string ID, string name, string Role) {
         try {
                //Some data manipulations 
                  return finalScore ; 
              }
         catch (Exception ex) { 
               //Response.Write(ex.ToString());
                                  } 
            } 

[/code]

//Client Side function 

[code:c#]

function score()
              {               
                  PageMethods.Score(txtID.value,txtName.value,txtRole.value);            
               } 

[/code]

<asp:HyperLink ID="btn_Test" runat="server" Text="Calculate" OnClientClick="javascript:return score();"/> 

Tags:
Categories: AJAX | ASP.NET | C#
Posted by vijay on Friday, August 24, 2007 12:23 PM
Permalink | Comments (0) | Post RSSRSS comment feed