postback

How to avoid duplicate entry from asp.net on Postback?

一个人想着一个人 提交于 2019-12-06 05:33:34
I have a dropdown list that pulls data from template table. I have an Add button to insert new template. Add button will brings up jQuery popup to insert new values. There will be a save button to save the new data. On_Save_Click I enter the new data and close the popup. Here is the proplem: When I refresh the page, the page entering the values again. So, I get duplicate entries! Question: How can I avoid this issue? I check out Satckoverflow and Google, both they suggest to redirect to another page. I don't want to redirect the user to another page. How can I use the same form to avoid this

How to force a postback with asp.net and C#

佐手、 提交于 2019-12-06 03:45:34
问题 I have a demo scheduled with a client and i need a quick and dirty fix for now. I will find a more appropriate work around tomorrow but for the time being i need a way to force a post back, or refresh the page. i tried: Response.Redirect(""); but it brings me to a page that says "Object moved to here". 'here' is a hyperlink that brings me to the page with desired results but i wish to bypass this message. Any ideas. 回答1: Response.Redirect("default.aspx"); (or whatever the name of the current

Maintain Control focus across post backs using PostBackOptions.TrackFocus

ⅰ亾dé卋堺 提交于 2019-12-06 00:39:14
Maintaining focus across post backs is an apparently difficult task. Searching Google, you will find a ton of people that desire the same thing, but all hook it up differently, and mostly, custom-ly. I would like to avoid a custom implementation, especially if there's a way it's supported by .NET. Only after some very deep searching, did I come across PostBackOptions.TrackFocus, mentioned quietly in another stack overflow post. According to MSDN: Gets or sets a value indicating whether the postback event should return the page to the current scroll position and return focus to the current

How DropDownList's SelectedIndexChanged() works without PostBack?

寵の児 提交于 2019-12-06 00:26:26
问题 DropDownList's SelectedIndexChanged() Event fills the ListBox on the page. Obviously this posts the page back to the server. Is there any way to make it happen without full postback? protected void ddlTablo_SelectedIndexChanged(object sender, EventArgs e) { List<string> list = new List<string>(); ListBox1.Items.Clear(); var columnNames= from t in typeof(Person).GetProperties() select t.Name; foreach (var item in columnNames) { list.Add(item); } ListBox1.DataSource = list; ListBox.DataBind();

Prevent duplicate postback in ASP.Net (C#)

Deadly 提交于 2019-12-06 00:07:29
问题 Simple one here... is there a clean way of preventing a user from double-clicking a button in a web form and thus causing duplicate events to fire? If I had a comment form for example and the user types in "this is my comment" and clicks submit, the comment is shown below... however if they double-click, triple-click or just go nuts on the keyboard they can cause multiple versions to be posted. Client-side I could quite easily disable the button onclick - but I prefer server-side solutions to

GridView RowDataBound doesn't fire on postback

[亡魂溺海] 提交于 2019-12-05 23:34:07
问题 On an ASP.NET page, I have a GridView populated with the results of a LINQ query. I'm setting the DataSource in code, then calling DataBind on it. In the GridView's RowDataBound event, I'm selectively hiding links in some GridView fields based on the query results. (For instance, I hide the "Show Parent" link of the row in question has no parent row.) This works fine initially. But on postback (when I don't call DataBind, but the GridView stays populated through ViewState), the data displays,

Postback problem when using URL Rewrite and 404.aspx

纵饮孤独 提交于 2019-12-05 22:37:09
I'm using URL rewrite on my site to get URLs like: http://mysite.com/users/john instead of http://mysite.com/index.aspx?user=john To achive this extensionless rewrite with IIS6 and no access to the hosting-server I use the "404-approach". When a request that the server can't find, the mapped 404-page is executed, since this is a aspx-page the rewrite can be performed (I can setup the 404-mapping using the controlpanel on the hosting-service). This is the code in Global.asax: protected void Application_BeginRequest(object sender, EventArgs e) { string url = HttpContext.Current.Request.Url

Prevent postback on Enter in a asp.net inputfield

↘锁芯ラ 提交于 2019-12-05 21:27:57
I have a problem with the key Enter in javascript and asp.net I have a control like this with a textchanged event which does a find but I want to control it when the user does enter <asp:TextBox ID="TextBox1" runat="server" onkeyup="EnterEvent(event)" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged" /> That's why I created this javascript function which works very well. Because it avoids the Enter postback at any character input function EnterEvent(e) { var keycode = (e.keyCode ? e.keyCode : e.which); if (keycode == 13) { return true; } else { return false } } And then I wanted to

How to determine which button caused postback

不想你离开。 提交于 2019-12-05 20:16:22
问题 I have 2 button controls. When I click one i'm trying to determine which one caused a postback in the page load. How to do determine this? 回答1: What about using CommandName and CommandArgument has shown in this example. This way you can have just one handler. <asp:Button id="Button1" Text="Sort Ascending" CommandName="Sort" CommandArgument="Ascending" OnCommand="CommandBtn_Click" runat="server"/> <asp:Button id="Button2" Text="Sort Descending" CommandName="Sort" CommandArgument="Descending"

Reloading page through javascript: avoid the “Postback” warning

一笑奈何 提交于 2019-12-05 17:56:43
I'm triggering a page reload through javascript, using the following: window.location.reload(true); However, in some cases (of previous postback), the browser is giving me the following warning "To Display the webpage again, the web browser needs to resend the information you've previously submitted...". Is there any way of avoing this message and just doing the postback anyway, because this might be confusing for the users? If I need to reload the page by another means, so be it. I don't think there is any way to do a postback without the message when you are doing the reload. Btw, whats the