postback

ASP.NET determine which button was clicked inside an updatepanel in page load event

独自空忆成欢 提交于 2019-12-07 05:35:47
问题 I'm trying to get my head around a page lifecycle issue of an ASP.NET UserControl. What I have is an updatepanel with two buttons in it. Now, in the Page_Load event I need to make a check to see which of the two buttons was clicked. I do know that I should use the click event for this, but this is a case of quite a complex page cycle with dynamically added controls and so on, so forth, so that is not an option, unfortunately :-( I've tried to check on the Request.Form["__EVENTTARGET"] value,

__doPostBack only works if there is a LinkButton, Calendar or WizardStep control on the page

ぃ、小莉子 提交于 2019-12-07 05:09:44
问题 I have identified a problem with __doPostBack and found a work around. I am seeking an explanation for the cause and/or a better solution than my work around. Scenario: I have a dropdown populated with the values; "-Select-", "One" & "Two". If the user selects "One" than client side script is executed. If the user selects "Two" than server side script is executed. Problem: The client script initiates the postback by calling __doPostBack. However, no post back actually occurs unless there is

ASP.net with C# Keeping a List on postback

爷,独闯天下 提交于 2019-12-07 04:58:38
问题 My situation goes like this: I have these lists with data inserted into them when a user presses an ADD button, but I guess on postback the Lists are re-zeroed. How do you keep them preserved? I've been looking for the answer, but I guess I don't quite understand how to use the session, etc. I'm very new to ASP.net and not much better with C# it would seem. public partial class Main : System.Web.UI.Page { List<string> code = new List<string>(); protected void Page_Load(object sender,

Properly implement a webpart with postback?

别等时光非礼了梦想. 提交于 2019-12-07 04:39:16
问题 What I'm trying to do is to create a webpart that has a textbox where you can set the value of a literal (h2) on the webpart and a "save" button that posts back and then sets the literal accordingly. This works with one huge caveat; when the page loads after the postback the literal has not been changed. However if I log what is actually set in the literal it has the new value. Also if I reload the page again (F5) it displays correctly. At first I figured it must be ViewState, so I disabled

Refreshing/Reloading side effect with ASP.net?

 ̄綄美尐妖づ 提交于 2019-12-07 02:49:08
问题 I'm relatively new at web & ASP.Net development, so bear with me. In the course of testing our web pages, I noticed that if a user were to click "Refresh/Reload", and clicks "Retry" when prompted on the "Resend Info" dialog box, whatever last event that was fired before the user chose to "Refresh", will subsequently be fired again. As an example we have "Previous" and "Next" Nav buttons which allows a user to navigate through a series of questions. Should the operator hit "Refresh/Reload",

Base class includes field but type not compatible with type of control

大憨熊 提交于 2019-12-06 18:29:49
问题 The base class includes the field 'lbl', but its type (web.App_Code.CustomLabelControl) is not compatible with the type of control (web.App_Code.CustomLabelControl). I had done many custom controls before the same way but Hell this error is driving me nuts. I have a web application project with the below class in App_Code directory a tagprefix reference in web.config for the control in class. What do I do now? Web.Config <system.web> <pages> <controls> <add namespace="web.App_Code" tagPrefix=

ASP.NET: Postback processed without events being fired

╄→尐↘猪︶ㄣ 提交于 2019-12-06 16:00:17
I have a GridView with dynamically created image buttons that should fire command events when clicked. The event handling basically works, except for the very first time a button is clicked. Then, the postback is processed, but the event is not fired. I have tried to debug this, and it seems to me, that the code executed before and after the first click is exactly the same as for any other clicks. (With the exception that in the first click, the event handler is not called.) There is some peculiarity in that: The buttons which fire the event are created dynamically through databinding, i.e.

How do I increment a step value to be processed when the page loads in ASP.NET?

和自甴很熟 提交于 2019-12-06 15:58:02
How do I increment a step value to be processed when the page loads? For example, in the code below the viewstate variable is not incremented until after Page_Load, due to the ASP.NET page lifecycle. protected void Page_Load(object sender, EventArgs e) { switch ((int)ViewState["step"]) { //do something different for each step } } protected void btnIncrementStep_Click(object sender, EventArgs e) { //when the button is clicked, this does not fire //until after page_load finishes ViewState["step"] = (int)ViewState["step"] + 1; } Just move the switch statement into an event that happens later. E.g

ASP.NET enter key and form submit with no javascript

和自甴很熟 提交于 2019-12-06 15:46:42
I have a form that I want to submit when the user presses the enter key. It works fine in Firefox, but not in IE. It is basically the same issue as this, except that I am not allowed to use any JavaScript: Enter button does not submit form (IE ONLY) ASP.NET Unfortunately it looks like ASP.NET uses JavaScript to process the button postback. Is there a way around this issue that doesn't rely on JavaScript? The fix for this is what was listed in the bottom of the page of your linked post. IE needs to have an additional form field for some reason for this to work. I have used this in many projects

How to set treeview's childnode postback false on ASP.NET?

女生的网名这么多〃 提交于 2019-12-06 15:40:49
I have a treeview and i want no postback on click any childnodes.And i will get selected childnode value. I found a solution , when i set "node_.SelectAction = TreeNodeSelectAction.None;" i cant select any childnodes and no highlight on it. Waiting your helps.Sorry about my en. Aspx: <asp:TreeView ID="TreeView1" runat="server"></asp:TreeView> Cs: TreeView1.Nodes.Clear(); TreeView1.TreeNodeExpanded += new TreeNodeEventHandler(TreeView1_TreeNodeExpanded); DataTable dt = ImzaDll.Imza.KategorileriGetir(true); foreach (DataRow row in dt.Rows) { TreeNode node_ = new TreeNode(); node_.Text = row[