Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-27
5
Medium Priority
?
847 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

618 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