how do I call a code-behind procedure from javascript?

K

Keith G Hicks

I'm working on an asp.net 2 app.

I had a page with an input button on it as shown here:

<input id="btnPost" type="button" value="Post" style="width: 66px" />

I need that button to run some code behind code that will update some data
in the associated sql 2005 dababase. I know how to write the codebehind
procedure That's not a problem. The problem is getting the javascript in the
input button to run the code behind procedure.

When I double clicked the input button (in the VWD designer) it of course
changed the definition of the button as follows:

<input id="btnPost" type="button" value="Post" style="width: 66px"
language="javascript" onclick="return btnPost_onclick()" />

and added the following to the page:

<script language="javascript" type="text/javascript">
<!--

function btnPost_onclick() {
// Not sure what to put here to call PostMissingClassmateData shown
below
}

// -->
</script>


I have this in the code behind file:

Partial Class Admin_MissingClasssmateSubmissions
Inherits System.Web.UI.Page

Protected Sub PostMissingClassmateData()
'This code will run a stored procedure in the backend

End Sub

End Class

Thanks,

Keith
 
J

Just Me

__doPostback('yourcontrolname') Something like that, you will see it in the
existing code.
 
K

Keith G Hicks

Never mind. I decided to alter the business rules for this issue. It no
longer applies.

Keith
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top