• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

OnClientClick

hey guys i have an asp button and two click method

OnClientClick
OnClick

i want to excute the OnClick first than OnClientClick but i do not know how to?

<asp:Button ID="btnAdd" runat="server" CssClass="button" Text="Add" ValidationGroup="a"
                            Width="90px" OnClick="btnAdd_Click"  />

see i have valiadators in my web page and when i click the button it goes into the OnClientClick method which is wrong.

it for to valiadate the page then move to OnClientClick method.

please help?
0
JCWEBHOST
Asked:
JCWEBHOST
  • 2
1 Solution
 
Ivo StoykovCommented:
you cannot because first into events chain comes ClientClick...

HTH

Ivo Stoykov
0
 
rajapandian_81Commented:
Hi,

If you want to call some javascript function after the event btnAdd_Click, add below code in last line of btnAdd_Click event.

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "spt", "<script type=\"text/javascript\"> JScriptFunctionName(); </script>");

Open in new window

0
 
JCWEBHOSTAuthor Commented:
protected void btnAdd_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "OnClientClick", "mainScreen.ShowConfirm(this,'Please confirm','Are you sure to add customers details?');", true);

        txtcellnumber.Text = "########";
    }

Open in new window


Guys this works and my javascript fires, how do i check if the uses click yes or no?

its hard to explain this, that onclick method display a message using ModalPopupExtender with a yes and no button.

my question is that my code on the above excutes

txtcellnumber.Text = "########";

before the user select yes or no.

if they a way that ScriptManager return a value to see if the user selects the yes button
0
 
JCWEBHOSTAuthor Commented:
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now