?
Solved

Calling the ASP.NET server side event handler from the jquery client side function

Posted on 2010-11-27
5
Medium Priority
?
845 Views
Last Modified: 2012-05-10
I have a server asp.net Button "btnSendmail".
Its server side  "On Click" event handler is "btnSendEmail_Click" ,and the client side function
on "OnClientClick" is "hideModal".

This button is on the AJAX modal pop up extender, I want that send eemail functionality of server side event handler executes first, and after I can call the client side script "OnClientClick" to close the modal dialog.
I have been trying this:
 function hideModal() {
          $find('mpUserNotificationBehavior').hide();
      }

It sems that its been cl,osing the Modal dialog without executing the server side event handler functionality..
How should I proceed in this situation.
The requirement is that I have to close the modal dialog once the server side is executed successfully.

Urgently required
0
Comment
Question by:Ammar Iqbal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
BurnieP earned 2000 total points
ID: 34222311
The OnClientClick will always execute first, so I suggest you remove it and add a script to be executed after your btnSendEmail_Click is fired.  Add a ScriptManager to your page and then your btnSendEmail_Click event should look like this :

protected void btnSendEmail_Click(object sender, EventArgs e) {
    // send your email
    ScriptManager.RegisterStartupScript(Page, this.GetType(), "ClosePopup", "<script>$find('mpUserNotificationBehavior').hide();</script>", false);
}

Hope it helps,

Burnie
0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 34222357
Do I need to write this Script Manager code  after my server side code?
0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 34222450
I am also invoking the Details View item inserting event in this btn Send email  event handler, IT has been invoked .,it is calling the insert event handler. but the record is not inserted ,and straight way  after this ,the script manager is executed.

One more question, Why the first parameter of script manger register script is "Page".Is it pointing to the page .or the modal pop up dialog
0
 
LVL 16

Expert Comment

by:BurnieP
ID: 34222459
Yes, you need to write this script manager code at the end of your server side code.

The first parameter Page will point to the Page.

Are you rebinding your details view after inserting the record?
0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 34222469
yes of ocurse, the  main point is that my button  is within the Panel of the modal pop extender, and here the record is not inserted.
IF i place this button outside the panel, and that Details view is inserting a new record succesfully
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question