Tuesday, March 31, 2009

Bind Link Button In DataGrid With Java Script

< asp:TemplateColumn HeaderText="ShowStudent" >
< ItemTemplate >
< a href='javascript: NewWindowForStudent( < % # DataBinder . Eval ( Container . DataItem, "Roll")%>,<%#DataBinder.Eval(Container.DataItem, "Name")%>)'>Show Student< /a >
< / ItemTemplate >
< / asp:TemplateColumn >

Saturday, March 28, 2009

Which methods are fired during the page load?

Init() - when the page is instantiated

Load() - when the page is loaded into server memory

PreRender() - the brief moment before the page is displayed to the user as HTML

Unload() - when page finishes loading.

Thursday, March 26, 2009

Tuesday, March 24, 2009

Naming Conventions

Pascal Casing convention :
capitalizes the first character of each word.


Camel Casing convention :
capitalizes the first character of each word except the first word.

• Pascal Casing
o Class Name e.g. StudentClass
o Method Name (Sub or Function) e.g. FindStudent()
o Interface Name e.g. Istudent


• Camel Casing
o Private Variables e.g. studName
o Local Variables e.g. studCount
o Parameters Name e.g. studRoll


• Upper Casing
o Namespace should include Company Name followed by Module or System Name. e.g. COMP_SALES
o Constants e.g. COMPANY_NAME


• Other Useful Note:

o Parameters Name should followed by small ‘p’ to differentiate with the local variable
o Do not prefix data type in local variable, since this is not helpful in modern
o development environment. E.g.: strLocalvariable, intLocalVariable.
Interface name should be Prefixed with capital ‘I’

Monday, March 23, 2009

Error ! there is no editor is available for .cs make sure the application for the file type(.cs) is installed

when you cannot see the form or form controls in visual studio.

go to Visual Studio Command Prompt and run the following commands.
Please close all the VS windows before running these commands.

devenv.exe /setup
devenv /resetskippkgs

Saturday, March 21, 2009

What is the difference between an interface and abstract class?

(1)
In an interface , all methods are abstract and there is no any implementation.
In an abstract class some methods can be concrete.

(2)
In an interface class, no accessibility modifiers are allowed like public,private they are all public by default.
An abstract class may have accessibility modifiers.

Thursday, March 19, 2009

What is property ?

A property is a thing that describes the features / characteristics of an object (i.e class). Suppose a "Chair" is a class , design name,color,brand will be its property.

Wednesday, March 18, 2009

What is an abstract class?

An abstract class is a class that must be inherited and it's method be overriden. In other word abstract class is a blueprint of a class without any implementation.

Tuesday, March 17, 2009

How to find if variable exist or null in javascript ?

When you want to know if the variable is null then you can use :

if ( null == var ) // with type casting
if ( null === var ) // without type casting

When you want to check existance of variable you can use :


if ( typeof var != ‘undefined’ ) // Any scope

Friday, March 13, 2009

Concatenate Rows Into A String Variable

DECLARE @Course varchar(Max)

SELECT @Course = COALESCE(@Course + ' , ', '') + Course_Name
FROM Course
where Course_Name like 'B%'

print @Course

Thursday, March 12, 2009

Run Stored Procedure In Asp.net With Parameters

SqlConnection cn = new SqlConnection();
cn.ConnectionString = "server=server;initial catalog=abc;uid=abc;pwd=abc;";
cn.Open();

SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "[dbo].[sp_Fetch_Context_Sensitive_Help]";
SqlParameter para1 = new SqlParameter("@Para1",SqlDbType.VarChar,500);
para1.Direction = ParameterDirection.Input;
para1.Value="1000";
SqlParameter para2 = new SqlParameter("@Para2",SqlDbType.VarChar ,-1 ); // for varchar(max)

para2.Direction = ParameterDirection.Output;


cmd.Parameters.Add(para1);
cmd.Parameters.Add(para2);



SqlDataAdapter adp = new SqlDataAdapter(cmd);


DataSet ds = new DataSet();
adp.Fill(ds);

Monday, March 9, 2009

Restrict length of multiline textbox in asp.net

function checkMaxLength( txt,e, length )
{

var mLen = txt[ " MaxLength " ];
if(null == mLen)
mLen = length;

var maxLength = parseInt ( mLen );
if(!isSpecialCharacters( e ))
{
if(txt.value.length > maxLength-1)
{
if(window.event)//for Internet Explorer
e.returnValue = false;
else// For Firefox
e.preventDefault();
}
}
}

function isSpecialCharacters(e)
{
if(e.keyCode !=8 && e.keyCode!=46 && e.keyCode!=37 && e.keyCode!=38 && e.keyCode!=39 && e.keyCode!=40)
return false;
else
return true;
}

add this in code behind file of the control

onkeyDown="checkMaxLength( this ,event ,'100' );"

Tuesday, March 3, 2009

Use Of TabStrip In Asp.Net

First Of All you have to install component art.




<%-- Register Component Art --%>

<% @ Register Assembly = "ComponentArt.Web.UI" TagPrefix = "ComponentArt" Namespace = "ComponentArt.Web.UI" % >

< %-- Register Your Page Or Control Here --% >

< % @ Register Src="~/wuc_MyUserControlOne.ascx" TagName="wuc_MyUserControlOne" TagPrefix="uc1" % >
< % @ Register Src="~/wuc_MyUserControlTwo.ascx" TagName="wuc_MyUserControlTwo" TagPrefix="uc1" % >

< componentart:tabstrip id="tbs_Name"
runat="server"
SiteMapXmlFile="~/file.xml"
EnableViewState="False"
MultiPageId="MP_Name">
< / componentart:tabstrip >

< ComponentArt:MultiPage ID = "MP_Name" runat = "server" CssClass="MULTIPAGE" >

< ComponentArt:PageView runat = "server" >
< uc1:wuc_MyUserControlOne ID="wuc_MyUserControlOne1" runat="server" />
< / ComponentArt:PageView >

< ComponentArt:PageView runat = "server" >
< uc1:wuc_MyUserControlTwo ID="wuc_MyUserControlTwo1" runat="server" / >
< / ComponentArt:PageView >

< / ComponentArt:MultiPage >




=============================================><=======================================
Your SiteMapXmlFile Will be as shown below

< ? xml version="1.0" encoding="utf-8" ? >
< tabs >
< tab id="zero" text="Zero"> < / tab >
< tab id="one" text="One"> < / tab >
< / tabs >

Monday, March 2, 2009

How to get ASP.NET Page Name at Runtime

System.IO.FileInfo fInfo = new System.IO.FileInfo(Request.PhysicalPath);

Response.Write( fInfo.Name);