.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Button specific code

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

I have 2 submit buttons on my page. Right now, the only way to run the code behind with razor is to to If(IsPost). Since I have 2 buttons, how would I destinguish between the two in post? Is there a way to request a button that sent a post request?  

View Complete Post

More Related Resource Links

Infopath button click event in custom workflow code.


Hi All,

I have designed the infopath form(Init) and integrated with my state machine workflow. i want to access button click event (designed in Infopath form) in my workflow code.

Can you help me.




Control this objectdatasource programatically from the code behind based on different button clicks

I have a page where you can search and display other data, very simple layout. 1 Gridview and 1 objectdatasource. But i have 4 possible buttons that can populate the gridview.. i would like to control my objectdatasource from the code behind based on the button you click. here is what i have right now.. but if possible, can this source not be hardcoded like this and only built in the code behind? <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SelectDVRInfo" TypeName="DataAccessCode"> <SelectParameters> <asp:ControlParameter ControlID="ddlDVR" Name="dvrInfo" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:ObjectDataSource> I found this site with a solution to this persons issue, but i cant seem to get mine working this way. http://stackoverflow.com/questions/2404264/overwriting-controlparameters-of-datasources-in-code-behind I have  this as the code behind right now when you press the button.. what other parameter settings am i missing and is this the right order to populate them for the source to acknowledge my values?   ObjectDataSource1.SelectMethod = "SelectDVRInfo"; ObjectDataSource1.SelectParameters["MyParameter"]

Code Behind (C#) - Postback - "If (this button was clicked) postback to this address, otherwise, do

Hello!!I have three buttons at the bottom of my form. Two of the buttons make the form invisible and make a Success message Visible.I need all three buttons to call SubmitForm Function to send us an email with the completed form.The third button is a PayPal button which I would like to postback to a different url after submitting the form via email.How can I change its Postback url in C# in the code behind.P.S. I tried Server.Transfer... got an errorThanks

Print Button +code in form

Using sharepoint 2010 and designed a simple form. How can I add the Print functionality to the ribbon from standard SP2010 NOT using Infopath? thx

Javascript code to copy specific cell of gridview row

Dears, I need a javascript code to copy the text content of a cell of a row in gridview. I have a button in each row that users click it and the text content a cell of that row should be copied in a textbox out of gridview

Enable a button based on a list via code behind


I've got a ListView with textboxes inside (bound to a property) and a button behind it.

I'd like to make the button enabled only when:

1) Each TextBox is not empty (each property has got a value)

2) Each TextBox has not got errors

How can I do it via code behind?


MOSS 2007 - Error Code 500 after click on Ok button on a post reply with an accent charactere in the



I have this strange behavior in my test and prod environment but not in my Dev.

The case is as following:

  1. Someone create in a discssion list a topic with an accent charactere in the title.
  2. Someone else click on the reply button. then he write the post.
  3. Then he click on the Ok button and a code error 500 page is loaded.

In the same discussion list If the title of the topic does'nt contain any accent charactere it works well !

Regional settings of the site collection are strictly identical on Dev, test and pro environment.

Does someone have any Idea ?

Thanks in advance for your answers



No OnClick-events on any button/ImageButtons on any page runs any code




I Simply drag a button from the toolbar onto a new page with a master page and a title, double click it so that I enter the Button1_Click function and sets a breakpoint and add some random code. The breakpoint nor the code never fires. I've tried this on several different pages and controllers, but with the same results: The page reloads, but no code is run.

I Have Tried:

Ive tried with three different webbrowsers with all plugins disabled.

I've tried to turn of Causes Validation, - Nothing changes.

I've tried to clean and Rebuild the project, - Still nothing.

I've tried to create a whole new project, - Does'nt work there either.

Other Information:

A RadioButtonList OnDatabound Event works, but whenever i try to do a Button or ImageButton click event the code for the event never fires. Ive programmed several webapplications in other versions of visual studio and ASP.NET but I have never encountered this problem before.

Breakpoints work in other parts of the code and the compile settings is set to DEBUG.


I am using

* Visual Studio 2010


* MVC 2.

Am I supposed to file a bug report or does anyone out there have a solution?

Many thanks in adv

Calling Button,s onclick event in javascript code


 Hi Experts.

I have a Button control in webpage.

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="test()"/>

When i click on button, i want to check some conditions

No "Edit Form Code" in Button Properties box.


Using InfoPath 2007. VSTA is installed. Also have VS 2008.

Want to test button onClick, but when I double click but in form design, I don't have the "Edit Form Code" button.

ALT-SHT-F12 opens VSTA, but no code automatically added for the onCLick event like it would be with Edit Form Code button.

Any suggestions or explanation why I can't see it?

How "press" a WPF button from within code?


How do I simulate the press of a WPF button from within code? I would like to call a method from within my code and have a particular button on a WPF form look like (visually behave like) it had been pressed and released (and presumably also fire its click event). I seem to recall doing this years ago with win forms and VB. Thanks!

Why? I have a form with several buttons and some keyboard shortcuts for those buttons. When a user presses the appropriate key, I would like to provide visual feedback that the key that was pressed was equivalent to a particular button.

specific code search


I have 25 websites in which each website have 500 pages. I want to know in which page the specific code was implemented let say if i want to know in which page <span>test<span> is implemented under each website. Is there any way to know through any tool or application.

I shall be very thankful if someone could help me.

C# Run onlick method in .cs code from href button


I have a css style button that is calling a method in the .cs file

loggut_Click is the method in the .cs file that button is gonna run

From the .... .aspx file

<a class="brochure" href="#" runat="server"><span>Logg ut</span>

have tried changing out the # with onclick="loggut_Click" but its still not working.

from the ....cs file 

protected void loggut_Click(object sender, EventArgs e)
Session["Innlogget"] = "nei";

Any suggestion on how to do this? All this button is gonna do is actually just set the Session "Innlogget" to "nei" as in you are not logged inn anymore. 

button style from cs code



How to add style to a buttton from the cs code.

I created a button, and rather than adding text, i want to attach an image to it from cs code. I have an image in the Images folder.

private Button btnNewButton; 

btnNewButton = new Button(); 

btnNewButton.Click += new EventHandler(btnNewButton_Click); 

From the design, I can do this:

<input id="Button2" type="button" style="background-image: url(images/Welcome.jpg); " />

How to style the button from the cs code.

Thank you


code for button in Default.cs


I want to write a button in code for under my table. When i click on that button there need to be an action, anyone?

               AantalKolommen = 4;
                        for (int j = 0; j < AantalKolommen; j++)
                            if (j < AantalKolommen - 1)

How can I add a unique search button which looks in a specific file?

I would like to add a search bar to our Sharepoint Site that will allow people to search a specific document (or documents) I have loaded onto our Sharepoint site. Basically, the people will be searching for Account Names and the results will return an Account Manager. 

how to set rules on submit button for this specific condition



I submitted  a form to the sharepoint site. The problem is when a user makes some changes and submits back again, it gets submitted back but is not using the condition and data connection that i have set for the submit button.  It uses the original submit option.  Can someone help me with this.  Thanks

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend