How To Call Javascript function in asp.net

H

hrishikesh

hi all can you tell me how to call javascript function
in .aspx page
i want to call it on onclick of button

this codebehind code giving me some other problem like
The viewstate is invalid for this page and might be
corrupted.
but it goes to that page

Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As
System.EventArgs) Handles Button1.Click
Dim TestString As String = "<script
language='javascript'>" & _

"
window.document.FrmConsultant.action='SearchResume.aspx';"
& _

" window.document.FrmConsultant.method='post';" & _

" window.document.FrmConsultant.submit()</script> "

Page.RegisterStartupScript("TestString", TestString)

End Sub

hrishi
 
G

Guest

Hi,

use

strScript = @"<script>


function MyJavascript()
{
do all your javascript manipulation/validations


return true; // if success
}


</script>"


Button1.Attributes.Add("onclick","return MyJavascript();")
Page.RegisterClientScriptBlock(strScript);


-Raja
 
Joined
Sep 20, 2008
Messages
11
Reaction score
0
See my post at social.msdn.microsoft.com/Forums/en/netfxjscript/thread/3efc7bf9-730f-47d0-bc9c-7a3550cf1282.

-Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top