Tuesday, July 26, 2011

Call Server side code from javascript

ServerSideCode:

In PageLoad method:
txtStartDate.Attributes.Add("OnChange", "javascript:return DoPostBack()");
Page.GetPostBackEventReference(txtStartDate);

txtStartDate_TextChanged(object sender, even..)
{
--Code called automatically
}

In Javascript:
function DoPostBack()
{
__doPostBack("txt_sssn_dt", "TextChanged");
}

No comments: