Results 1 to 3 of 3

Thread: Javascript Issues

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    23

    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

  2. #2
    PowerPoster JPnyc's Avatar
    Join Date
    Oct 2002
    Location
    Manhattan
    Posts
    3,015

    Re: Javascript Issues

    Well for starters if you plan to use double quotes through the string, you have to escape one of em.

  3. #3
    Addicted Member rabid lemming's Avatar
    Join Date
    Feb 2005
    Posts
    210

    Thumbs up 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

    I will wait for death with a smile and a big stick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width