button click event from another button click not firing


 Hi,

 I want to trigger a button click event from another button click .It is not firing.

 Please help.

 

protected void btnReview_Click(object sender, EventArgs e)

{

       if (MandatoryValidation())

       {

         this.Button1.Click += new System.EventHandler(this.Button1_Click);

      }

}

protected void Button1_Click(object sender, EventArgs e)

{

}

0
rajasreepradeep
7/23/2008 10:28:27 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

8 Replies
3498 Views

Similar Articles

[PageSpeed] 2
Get it on Google Play
Get it on Apple App Store

protected void btnReview_Click(object sender, EventArgs e)

{      

      if (MandatoryValidation())

     {

        this.Button1.Click += new System.EventHandler(this.Button1_Click); //The event is registered not called.

        Button1_Click(null, null);

      }

}

protected void Button1_Click(object sender, EventArgs e)

{

}

Hope that helps Yes 


Techie (.Net Knowledge at its Best)


We make a living by what we get, but we make a life by what we give.
::: Winston Churchill :::
0
PassHours
7/23/2008 11:21:06 AM

 protected void btnReview_Click(object sender, EventArgs e)

{

       if (MandatoryValidation())

       {

         Button1_Click(null,null);

      }

}

protected void Button1_Click(object sender, EventArgs e)

{

}


Kamran Shahid
Sr. Software Engineer
(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])
Netprosys Inc.
www.netprosys.com

Remember to click "Mark as Answer" on the post that helps U
0
kamii47
7/23/2008 11:21:42 AM

Hi,

Well..i have a same sort of problem.. :(

i have an asp page having a panel..i have also created 2 web user controls having a button each..on each button click, i hav defined a public custom event..now when i load 1st user control on default page's pannel dynamically, it works fine but when i try to load the other user control on the 1st user control's button's click, then the 2nd user control's custom event is not firing...

following is my code..

// WebUserControl1 code behind:

protected void Button1_Click(object sender, EventArgs e)

{

if (Button1_Clicked != null)

{

Button1_Clicked();

}

}

public delegate void OnButton1_Clicked();

public event OnButton1_Clicked Button1_Clicked;

 

// WebUserControl2 codebehind:

protected
void Button2_Click(object sender, EventArgs e)

{

if (Button2_Clicked != null)

{

Button2_Clicked();

}

}

public delegate void OnButton2_Clicked();

public event OnButton2_Clicked Button2_Clicked;

// Default.aspx.cs

protected void Page_Load(object sender, EventArgs e)

{

 

WebUserControl1 UC1 = (WebUserControl1)LoadControl("WebUserControl1.ascx");UC1.Button1_Clicked += new WebUserControl1.OnButton1_Clicked(UC1_Button1_Clicked);

Panel1.Controls.Add(UC1);

 

}

void UC1_Button1_Clicked() // this method is working fi9 and i m able to load the 2nd user control..

{

Panel1.Controls.Clear();

WebUserControl2 UC2 = (WebUserControl2)LoadControl("WebUserControl2.ascx");UC2.Button2_Clicked += new WebUserControl2.OnButton2_Clicked(UC2_Button2_Clicked);

Panel1.Controls.Add(UC2);

}

void UC2_Button2_Clicked()  //this method is not invoking when i m clicking on 2nd user control's button..!!!

{

Panel1.Controls.Clear();

//do something..

}

 

kindly tell me where m i makin mistake..

Thanks.

Regards,
Shayan Malik.

0
shayan
7/23/2008 11:50:36 AM

Thanks..:) ..it is resolved.

0
rajasreepradeep
7/23/2008 11:51:11 AM

I have one more problem related to the above button click event. 

The Button1 has a attribute OnClientClick.

The click event of Button1 is executed but OnClientClick is not triggering , any idea what can be the reason.?

Will OnClientClick trigger when we do the click event of button manually..? or is it something not possible.?

Please help..

0
rajasreepradeep
7/24/2008 4:56:53 AM

whether u written any javascript function on

assign the function name and check it


Regards,
M.Venkatesan
My Blog : http://venkat-dotnetsamples.blogspot.com


Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
venkatu2005
7/24/2008 5:44:37 AM

 

yes ,

I have written javascript function and  called like this .

<asp:Button ID="Button1" runat="server" Text=""  Visible="true" OnClientClick="return OnClickReview();"

onclick="btnButton1_Click" />

and also i have tried like

Button1.attributes.Add("OnClientClick" , "return OnClickReview();");

 

0
rajasreepradeep
7/24/2008 6:04:26 AM

hi give ur javascript function ...

and check whether with breakpoint. it will to the code or not..

 


Regards,
M.Venkatesan
My Blog : http://venkat-dotnetsamples.blogspot.com


Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
venkatu2005
7/24/2008 6:23:44 AM
Reply:

Similar Artilces:

Button click firing another button event
I am using asp.net 2.0 with C#.  I am trying to achieve the following: I have two user controls, on Page1.ascx i have a submit button that submit values onto Page2.ascx.  Also, on Page2.ascx i have a hidden submit button that i want to be fired whenever i click Page1.ascx submit button.  How do i access one button from one user control to another?  As far as I know, you don't. You could have button1 set a form field that the page2 page_loads looks for and then it can fire button2 click...Please Mark As Answer posts that helped you."If we learn from our mistake...

need help, when clicking on button1, it fires the another button's click event?
Hi Guys,I am using asp.net 2 and vs.net 2005.I have a simple page with datagrid and there button -- "Show" "Hide" "Refresh"Click on "Show" to display the datagridClick on "Hide" to hide the datagridClick on "Refresh" to refresh the datagrid data"Show" button and "Hide" button are woking fine.The problem is "Refresh" button and when I click on "Refresh" button, the data refresh is ok. However, the datagrid is dispear. It seems like when clicking on button "Refresh", it fire the "Hide" button's click eventl. Does anyone have this problems before?Thsnks in advance...Justin If the datagrid ref...

How to call click event of button apart from clicking on the button.
I want to call click event event of my button and run codes within the event, not clicking on the button itself. For instance in Page_Load event of my page i want to call it. How can i handle this? Thanks in advance. Hi, Try this  Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load If Not IsPostBack Then Me.Button1_Click(sender, e) End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Response.Write("Hello World!!!") End Sub  ...

Button click event fired only on clicking twice
Hi, My application is developed using VS 2005 - Web Application. In one of the pages, I added a button and a click event for the same. On clicking the button I perform some operation. But only if i click the button twice, the click event is fired. I tried every thing from rebuilding the solution to adding the button controls dynamically but of no avail. Any pointers? Thanks, Sandhya Hello Sandhya, Would you please post the entire page including the .aspx and .aspx.cs/vb? It would be helpful to track down the problem. Thank you, JessicaJessica CaoSincerely,Microsoft Online Communit...

Button click event not firing on the first click
I have three buttons on my form but when I click on the button, it does not fire the button click event. I looked at the call stack. However when I click on the second time it does. I have three buttons and they all act the same way. Here is a sample of my code private void btnSubmit_Click(object sender, System.EventArgs e) { this.dgResults.CurrentPageIndex = 0; FillGrid(); } private void btnExport_Click(object sender, System.EventArgs e) { this.dgResults.CurrentPageIndex = 0; this.dgResults.AlternatingItemStyle.BackColor =System.Drawing.Color.White; this.dgResults.AllowPaging =...

Click Event not firing when submit button is clicked
I have a form with several textboxes, one dropdown list, and a checkbox.  If I type something into a textbox and click on the submit button, the click event for the submit button does not fire, though the form does postback.  If I click on it again, it will fire the click event.  On the other hand, if I click on the checkbox, or dropdownlist, rather than typing into the textbox, then click on submit, it fires as expected.  Does anyone have an explanation and solution?  Thanks in advance for any help! Elliott post your code - sounds like postback...

Call a buttons click event from another button??
Hi, in asp.net vb.net how do you call a buttons click event from another procedure?In standard vb it is easy not sure what to do in .net though because of the parameters.Thanks for the help. Graham.<code> Private Sub CloseBtn_Click(ByVal sender As System.Object, ByVal e As   System.Web.UI.ImageClickEventArgs) Handles CloseBtn.Click ' close the browser window.HttpContext.Current.Response.Write("<script>window.close();</script>") End Sub Private Sub ProcessBtn_Click(ByVal sender As System.Object, ByVal e As  System.Web.UI.ImageClickEventArgs) Handles Pro...

An OnClick event doesn't fire up when a button is clicked in a Tab Panel in a Tab Container in an AJAX Web Form
Hello Post: I would like to enclose the following code so you can analize what is going on: "> " style="vertical-align:top;"> "> "> ...

Link Button Event not Getting Fired when the button is clicked
Hi In the Inline code , i have any tables within a form. when i try to click the link button, the button event is not getting fired. Can any on slove this for me. Thanking you Solomon Hello, we would really want to help you, but we need to know more information, can u post some code please. regards.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP i think the handles part is not there for the for that event. Search for handles linkbutton1.click in codebehind. if not found add it....

How to handle another button action in button click event
Hi, all. I want to handle in button handling code another button click event. My code processing long time process. Durling this process, another button click event is suspended until this process finish. But I want to cancel this process by clik another button. Please teech me how to know another button click is happend. my code is as follows. void __fastcall TForm1::Button7Click(TObject *Sender) { rf_freq = Edit1->Text.ToInt() * 1e6; stop_freq = Edit2->Text.ToInt() * 1e6; lo_freq = rf_freq - 1e6; start_freq = rf_freq; stop_freq = stop_freq; mod = 200; ...

Image button .click event not firing the first time clicked
I have an image button that saves a record to my backend. It has the CausesValidaton property = "True". The first time, the button is clicked, it causes a postback, but the image buttons .click event is not fired. For each subsequent click, the postback gets called, then the image buttons .click event is fired as expected. I have done this simple task numerous times, so I'm a little stumped. I've troubleshot everything I can think of (including cross referencing all the properties of both the page and control against working production examples). Here's the handler for my button. Thanks fo...

Button Click event not fire when button is in updatepanel -> popupcontrol
I am having difficulty in my code to run code of button click. Button are present in different popupcontrols. And all saving data in my database.  I have no idea why button_click event don’t work. I even use triggeres for that but of no use.  View the output at page: http://www.artinarts.in/ecomm/admin/product.aspx  This is my product.aspx page code: <%@ Page Title="" Language="VB" MasterPageFile="MasterPage.master" AutoEventWireup="false" CodeFile="Product.aspx.vb" Inherits="admin_Product" %> &l...

Button clicks another button
 Basically I want a button to be triggered("clicked") by the first button when the first button is clicked. Is there a way to handle this in the code behind? In the click event of the first button, you can call the event handler function written for the other button. Here is a forum link, where the person wanted to trigger a server event.http://forums.asp.net/t/900763.aspx If you coluld explain what your actual requirements are, it would help. Set the Click event of the first button to the event of the second button. Ie. <asp:Button ID="Button1...

How to make radio buttons reflect what was click in a button in another form
I have 2 forms.   In Form1, when I click on the OK button it should bring me to Form 2 where in Form 2, the OK radio button must be selected.  Similarly, when I click on the Reject button in Form 1, it should bring me to Form 2 where in Form 2, the Reject button must be selected. A bit more info about Form 2: Form 2 has a datagrid in which each row shows a transport claim made by a staff over a period of a month. The radio buttons are found at the end of each row which would indicate if the claim is OK or Rejected. Would appreciate if the codes ar...

Button clicking another button
I have two user controls each having a button.  I want on Page1.ascx when the user clicks that button it allows clicks or activates the Page2.ascx button event as well.  How do i make both User controls communicate that way?? I am using asp.net 2.0 with c#.  Define the event for the click event of the buttons as usual but button one will also have a delegate to the button two event:this.ButtonOne.Click +=new EventHandler(ButtonOne_Click); this.ButtonOne.Click +=new EventHandler(ButtonTwo_Click);this.ButtonTwo.Click += new EventHandler(ButtonTwo_Click); Create the e...

I double click a button but no event handle in source view why, go to button properties,events,onclick, try to create event handle but its where. Only the button markup.
I have a button, if double click it no handle is created. Iam only taken to the buttons' markup in source view. This is happening on all pages through out the whole solution. Possible cause is, this project was not ajax enabled, i installed ajax, edited the web.config file of this project to make the site ajax enabled. I had to build the solution and got no errors, every thing is ok a part from double clicking all controls not being able to get to their event handles.--------------------------------------------------No Project Too Eazy.-------------------------------------------------- ...

How could i go to the another web form by click button ?
If i work on (default.aspx) page and i want to click button and go to (page1.aspx) , what should i write in ( Button1_Click ) or in button proparity ? Hi,in your click event you can write:Response.Redirect("page1.aspx");Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Make sure that the code is type in the click event of the next page that you want to go to You can use either response.redirect("Page1.aspx") or server.transfer("page1.aspx")...

How to fire the button click event in web part?
If I created a button control programmatically in a web form, I would use   public Button btnSearch = new Button();protected override void CreateChildControls(){ Button1.Click += new System.EventHandler(this.Button1_Click); this.Controls.Add(Button1); } protected void Button1_Click(object sender, EventArgs e) { //code here. }It doesn't work in a web part. It bombed at this.Controls.Add(Button1); after I clicked the button. How does the button click event get fire in web part? Thanks.DY  Im a bit confused here.. can you elaborate more? What really is your re...

ASPX Web Form window jumps when link button or button is clicked
Dear, i m senthil, and i m new to asp.net I m using asp.net with vb, my problem is, i m creating a forum, in all web pages while clicking any link button or command button the webpage jumps and the focus is going to some other controls. I want the page not to get jumped... Pls help in this regard. set the MaintainScrollPositionOnPostback property of your page to true. http://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback.aspxMike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.co...

Button doesnt fire click event after some clicks and keep loading on brower...
Hello All, I  m calling Button Click event on my parent using the following JS functionfunction btnRefreshClick() {var refresh = document.getElementById('<%= Button5.ClientID%>'); document.getElementById('<%=Button5.ClientID%>').click();} This works fine but after appx 5 click event, no more events fire ( I put breakpoints and find out) and nothing happens on browser excpet you see that page is trying to load. If i let it , after some time  i will that IE cant display page. The address on the bar is even a valid address but cant do anything. I...

button click event not firing for dynamic buttons added on PreRender of the updatepanel
Hi,i have a webpage with an updatepanel updatepanel1.i am adding controls dynamically to the updatepanel on the prerender event.i am using the prerender event as i want to get the latest bata from thedatabase which include the data i have inserted on my last button click.But the button click event is not getting trigged on clicking the button.Here is the sample code in PreRenderSqlCommand cmd = new SqlCommand("SELECT Heading, ID FROM tblNews ORDER BY ID;", conn);conn.Open();SqlDataReader sqlData =cmd.ExecuteReader(CommandBehavior.CloseConnection);while (sqlData.Read()){lblHeading =...

How to trigger the button's Click event only when user really click it. (Escape the return button)
Hi, I want the user really click the button, then exec the code in btnSubmit_Click event . Not by pushing the <return> button. Does anybody have any idea about this? Thanks Create a separate Subroutine that does all the stuff you need the click event to do (separate from the Button's click event)Then, in the button's click event - call that event. At this point, you can also call it from anywhere else in your application that you'd like.David WierMCP/ASPInsiderASPNet101.com - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper ...

Button click event vs button command event
Hi, Can any one tell me whats the difference between the two events, and when to use which one? Thanks. Check out this article on event bubbling: Bubbling Events Up the Control Hierarchy Summary: The DataGrid control, as you likely know, can easily be configured to add a column of buttons. By adding a ButtonColumn, whenever one of the DataGrid's buttons in the column is clicked, the Web page posts back and the DataGrid's ItemCommand event fires. In fact, the same behavior can be noted if you manually add a Button or LinkButton control into a DataGrid TemplateColum...

button click click click sound!
Ok stupid question time!Could somebody tell me if it is possible to remove the 'click' sound a button makes when you click on it?The image button doesn't do this. Only normal and linkbuttons. (Ok, auto-postback on dropdownlists do this as well!)I'm busy building a internal system using ATLAS which makes for an awesome experience.However the button click sound is giving it my secret away and killing mah magic! It's a client thing, not a server thing... Dont use a standard button, use your own control with onmousedown or some such.... The sounds are determined by t...

Web resources about - button click event from another button click not firing - asp.net.web-forms

Scalia’s death may help liberals dodge losses in Affirmative Action and Union cases
Likely Conservative victories now look like liberal-benefiting deadlocks

‘Tonight Show Valentine’s Day Special’ Ratings Top Slow Sunday, ‘Simpsons’ Down, ‘Madam Secretary’ Up ...
There was neither Super Bowl nor a Grease Live! dominating primetime on Sunday and the Grammys isn't on until tonight. In fact, with specials ...

TIDAL Flubs Kanye West’s Album Release
Digital music service TIDAL climbed to the top of the App Store, thanks to scoring the exclusive rights to Kanye West’s new album, “The Life ...

Ted Cruz Warns Donald Trump Would Nominate A Liberal Justice
It wasn't long after the death of Supreme Court Justice Antonin Scalia before Sen. Ted Cruz (R-Texas) seized the opportunity to formulate a new ...

What it's like to be Drake's guardian angel at the NBA All-Star Game
From Meek Mill to President Obama , Drake’s legion of enemies has grown, along with his paranoia — leaving him dangerously exposed during “ the ...

Would 'The Revenant' as an old-timey silent movie still get an Oscar nom?
Remember the good ol' days before movies had gigantic budgets and spectacular special effects? Neither do we. But there was once a time when ...

Why life as a zombie on 'The Walking Dead' would actually be paradise
The world of AMC 's The Walking Dead is a grim place full of violence and despair. Amid the anarchy of the zombie apocalypse, the survivors must ...

Hulu's universal Windows 10 app features live tiles and Cortana
Nathan Ingraham / Engadget : Hulu's universal Windows 10 app features live tiles and Cortana — A big part of the promise of Windows 10 is the ...

Avril Lavigne, Chad Kroeger Back Together? Couple Seen At Pre-Grammy Party
Just months after a split was announced, the Avril Lavigne-Chad Kroeger relationship is back on again. The couple, who separated in September ...

Monday Morning News: Scalia, Adidas, Star Wars, Gay Slurs, Ian Thorpe
FREE AS MY HAIR. Zayn Malik goes pink. pic.twitter.com/CRCFxRMtdd — zayn (@zaynmalik) February 13, 2016 CONSPIRACY THEORIES. Scalia was murdered ...

Resources last updated: 2/15/2016 6:33:41 PM