RegisterClientScriptBlock to register OUTSIDE form tags

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default RegisterClientScriptBlock to register OUTSIDE form tags

    Hello,

    I currently have javascript and vbscript that needs to be spat out based on
    certain conditions in the codebehind. My vbscript code relies on the OnLoad
    event. However with the RegisterClientScriptBlock(), sticking the code in
    the form tags, I cant seem to get the bastard to work.


    Basically heres what I *NEED* to do. Generate some js and vbscript to be
    output before or after the form tags.

    I tried defining the variables in the codebehind with the protected
    modifier... then setting them in Page_Load... and then doing <%=myVar%> and
    nothing gets spat out to the browser.

    If anyone could *PLEASE* give me any words of wisdom, they would be greatly
    appreciated.

    Wes


    Wes Weems Guest

  2. Similar Questions and Discussions

    1. Please help, I am not able to register C++ CFX Tags
      I was expecting to see a button on the Extensions > CFX Tags page inside CF Administrator but I don't see it there or anyplace else. Let me tell...
    2. #25676 [Opn->Bgs]: Form hidden input ouput when any form=* is in url_rewriter.tags
      ID: 25676 Updated by: sniper@php.net Reported By: davey@php.net -Status: Open +Status: Bogus Bug...
    3. #25676 [Opn]: Form hidden input ouput when any form=* is in url_rewriter.tags
      ID: 25676 Updated by: davey@php.net Reported By: davey@php.net Status: Open Bug Type: Session related...
    4. #25676 [Bgs->Opn]: Form hidden input ouput when any form=* is in url_rewriter.tags
      ID: 25676 Updated by: davey@php.net Reported By: davey@php.net -Status: Bogus +Status: Open Bug...
    5. #25676 [NEW]: Form hidden input ouput when any form=* is in url_rewriter.tags
      From: davey@php.net Operating system: WinXP/FreeBSD PHP version: 4CVS-2003-09-26 (stable) PHP Bug Type: Session related Bug...
  3. #2

    Default Re: RegisterClientScriptBlock to register OUTSIDE form tags

    Hi Wes, you might find that RegisterStartupScript does what you need since it
    runs on load or thereabouts.

    In your code behind:

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim strName As String = "Wes"
    RegisterStartupScript("start", _
    "<script>sayHello('Hello " & strName & "');</script>")
    End Sub

    ' In your .aspx page:

    <script language="javascript">
    function sayHello(strMsg) {
    alert(strMsg);
    }
    </script>

    Ken
    MVP [ASP.NET]


    "Wes Weems" <wweems3.SPAM@charter.net> wrote in message
    news:vhj048q3b7gm64@corp.supernews.com...
    Hello,

    I currently have javascript and vbscript that needs to be spat out based on
    certain conditions in the codebehind. My vbscript code relies on the OnLoad
    event. However with the RegisterClientScriptBlock(), sticking the code in
    the form tags, I cant seem to get the bastard to work.


    Basically heres what I *NEED* to do. Generate some js and vbscript to be
    output before or after the form tags.

    I tried defining the variables in the codebehind with the protected
    modifier... then setting them in Page_Load... and then doing <%=myVar%> and
    nothing gets spat out to the browser.

    If anyone could *PLEASE* give me any words of wisdom, they would be greatly
    appreciated.

    Wes



    Ken Cox [Microsoft MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139