How To Call Javascript function in asp.net

  • Thread starter Thread starter hrishikesh
  • Start date Start date
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
 
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
 
Back
Top