Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith G Hicks - 30 Mar 2008 19:44 GMT
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
Scott M. - 30 Mar 2008 20:14 GMT
Why don't you just use a Button server control and your problem is solved?

> I'm working on an asp.net 2 app.
>
[quoted text clipped - 42 lines]
>
> Keith
Just Me - 30 Mar 2008 21:10 GMT
__doPostback('yourcontrolname') Something like that, you will see it in the
existing code.

> Why don't you just use a Button server control and your problem is solved?
>
[quoted text clipped - 45 lines]
>>
>> Keith
Keith G Hicks - 30 Mar 2008 23:12 GMT
Never mind. I decided to alter the business rules for this issue. It no
longer applies.

Keith

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.