-
Javascript Issues
***for some reason when my Javascript fires it causes the objects on the page to change...the textboxes are a different size, the font changes & the grid also....this a sample of some of the code i'm using...
If txType.Text = "IntermittentFMLA" Or txType.Text = "FMLAMoreThan40" Then
If cbPaid.Checked = False And cbUnpaid.Checked = False And cbPartialPaid.Checked = False Then
Dim message As String = "Please select pay status!"
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" & message & """)" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
cbPaid.Focus()
Exit Sub
End If
any advice!!!! help :sick:
-
Re: Javascript Issues
Well for starters if you plan to use double quotes through the string, you have to escape one of em.
-
Re: Javascript Issues
Yer JPnyc is absolutely right use this instead:
Code:
Dim onloadScript As New System.Text.StringBuilder()
onloadScript.Append("<script language='javascript' type='text/javascript'>" + vbCrLf)
onloadScript.Append("<!--" + vbCrLf)
onloadScript.Append("alert('Message');" + vbCrLf)
onloadScript.Append("//-->" + vbCrLf)
onloadScript.Append("<" + "/script>")
' Register script with page
Me.ClientScript.RegisterStartupScript(Me.GetType(), "onLoadCall", onloadScript.ToString())
Or
Code:
System.Web.HttpContext.Current.Response.Write("<script language='javascript' type='text/javascript'>" + vbCrLf)
System.Web.HttpContext.Current.Response.Write("<!--" + vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert('Message');" + vbCrLf)
System.Web.HttpContext.Current.Response.Write("//-->" + vbCrLf)
System.Web.HttpContext.Current.Response.Write("<" + "/script>")
Hope that helps :thumb: