Wednesday, May 21, 2008

Call javascript function on coditiona bassis of c#

// May 21, 2008
if (IsPostBack)// when it will post back
{
string str = "hello()";


Page.ClientScript.RegisterStartupScript(this.GetType(), "adf", str,true );

}
else // when first time page laod
{
string str = "hello()";


Page.ClientScript.RegisterStartupScript(this.GetType(), "adf", str,true );

}

On JavaScript Section

[script language="javascript" type="Text/javascript"]
function hello()
{
alert('hi');
return false;
}
[/script]



Or Simply we can use it

if(true)
{

string strhelpondesk = " [ script language='javascript'] document.getElementById('ctl00_ContentPlaceHolder1').style.display = 'block'; [/script]";
Page.RegisterStartupScript("strhelpondesk", strhelpondesk);


}

Thanks
HElpondesk team

No comments: