execute or call client side script on server side
Hi, how can I call a client side script on server side?
one thread here said use response.write("<script language = 'javascript>function Hello() {alert('hello');}</script>") but I tried it and it doesn't work, asp.net doesn't write it as text on the page but it doesn't execute the script too....
please help...
thanks
Re: execute or call client side script on server side
Use Page.RegisterClientScriptBlock to have the function written to the page, and use
Page.RegisterStartupScript("myscript", "<script language=javascript>Hello();</script>")
to call it.
Re: execute or call client side script on server side
Hi, this doesn't call the script right? It needs another control that calls it ex. onClick or onLoad...etc...I need something that calls a script inside a code behind procedure...
for example:
Code:
public sub Load
response.write ("hello");
executeScript here....
.
.
.
End sub
Re: execute or call client side script on server side
In place of "executescript here...." put
Page.RegisterStartupScript("myscript", "<script language=javascript>Hello();</script>")
Re: execute or call client side script on server side
Thanks...
I put :
Code:
Page.RegisterStartupScript("my", "<script language=javascript>function Hello(){alert('hello');}</script>")
that's why it didn't run...thanks...
Re: [resolved]execute or call client side script on server side
Does this mean your problem is solved?
Re: execute or call client side script on server side
Hi, its me again, what if it's a vbscript?
I tried
Code:
Page.RegisterStartupScript("my", "<script language=vbscript>
Call mySubPro</script>")
:( please help
Re: execute or call client side script on server side
Does mySubPro exist on the page?
Re: execute or call client side script on server side
Re: execute or call client side script on server side
This is probably related to your other problem... the sub doesn't exist on the page, but you are generating it too.
I'd suggest you either generate it properly or write it directly onto the page.