Hi,
can anyone show me how to handle client side script with asp.net? make sense? how will client side script communicate with code behind?
Thanks,
Jewel
Printable View
Hi,
can anyone show me how to handle client side script with asp.net? make sense? how will client side script communicate with code behind?
Thanks,
Jewel
You can use two methods: Page.RegisterStartupScript to make some js run immediately, or Page.RegisterClientScriptBlock to add some javascript to your page. You generate the javascript in the codebehind with your controls, or whatever logic you want.
hi, thanks...can you give me an example please...
Example:
VB Code:
Dim strJS As String strJS = "<script language=JavaScript>function selectAll(intAction){" & _ "if(intAction==0)" & _ "{" For i As Integer = 0 To strArrayA.GetUpperBound(0) strJS &= "document.getElementById('" & strArrayA(i).ToString() & "').checked = true;" Next strJS &= "}" & _ "else" & _ "{" For j As Integer = 0 To strArrayD.GetUpperBound(0) strJS &= "document.getElementById('" & strArrayD(j).ToString() & "').checked = true;" Next strJS &= "}}</script>" Page.RegisterClientScriptBlock("theselectallfunction", strJS)