Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RegisterClientScriptBlock to register OUTSIDE form tags

Reply
Thread Tools

RegisterClientScriptBlock to register OUTSIDE form tags

 
 
Wes Weems
Guest
Posts: n/a
 
      07-19-2003
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


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      07-19-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
CallForward outside->inside->outside failed after one ring. Yogz Cisco 1 04-16-2007 03:58 PM
nat from outside to outside dt1649651@yahoo.com Cisco 1 08-21-2005 04:26 PM
RegisterClientScriptBlock requires <FORM> tag or script will not appear pealy2@bigfoot.com ASP .Net 0 05-26-2005 11:03 AM
Re: js script block outside form tags... Alex Wagner ASP .Net 2 04-19-2004 11:14 PM



Advertisments