MVC :: How To Determine Which Event Caused The Postback

May 13, 2010

Currently I have two events in my view that can trigger the post back (A dropdownlist and a submit button).

1. <%= Html.DropDownList("List", ViewData["Days"] as SelectList, "--Choose Day--", new { onchange = "this.form.submit();" })%>

2. <input type="submit" value="Submit"/>

When either of these are used, it they both call the [AcceptVerbs(HttpVerbs.Post)] Index() method.

What I want to know is how can I know which event caused the postback, because I need to process each one differently.

View 2 Replies


Similar Messages:

How To Determine The Index That Caused The Selectedindexchanged Event To Fire

Aug 4, 2010

I have seen a million forums ask this question. This is what has been working for me.

protected void checkboxlist_SelectedIndexChanged(object sender, EventArgs e)
{
CheckBoxList list = (CheckBoxList)sender;
string[] control = Request.Form.Get("__EVENTTARGET").Split('$');
int idx = control.Length - 1;
string sel = list.Items[Int32.Parse(control[idx])].Value;

I'm way off and have just been lucking out, but I haven't seen a case where the index wasn't the last value in a '$' terminated string.

View 4 Replies

Determine Which Control In Window.onbeforeunload In Javascript Caused Event

Mar 7, 2011

I have set up in javascript:

var onBeforeUnloadFired = false;
window.onbeforeunload = function (sender, args)
{
if(window.event){
if(!onBeforeUnloadFired) {
onBeforeUnloadFired = true;
window.event.returnValue = 'You will lose any unsaved changes!'; //IE
}
}
else {
return 'You will lose any unsaved changes!'; //FX
}
windows.setTimeout("ResetOnBeforeUnloadFired()", 1000);
}
function ResetOnBeforeUnloadFired() {
//Need this variable to prevent IE firing twice.
onBeforeUnloadFired = false;
}

I'm trying to achieve an edit screen where the user is warned before navigating away. It works fine except I get the pop up for normal post backs of button clicks. I'm hoping to avoid this so I'm figuring if I could determine which button was pressed it would work. Does anybody know how to determine which button was pressed in the indows.onbeforeunload? Alternatively anyone know a better approach to what I'm trying to achieve?

View 1 Replies

Web Forms :: Determine What Caused The 404 Error

Mar 30, 2010

I would like to send along the page address that caused a 404 error in my custom 404.aspx file. Is this possible?

I'm using a redirect in the webconfig if a status code of 404 is encountered.

View 4 Replies

Determine The Error That Caused A Redirect In C#?

Sep 7, 2010

I have an ASP.NET web form application. In the web.config associated with this application, I handle my custom error like so:

<customErrors mode="Off" defaultRedirect="error.aspx" />

When a user gets to the error.aspx page, I want to determine what error caused this page to get reached.

View 2 Replies

Determining The Control That Caused A PostBack

Jul 16, 2010

can I retrieve the name that caused a postback? (VB.NET)

View 5 Replies

Determining Which Button Caused The Postback In An UpdatePanel?

Oct 18, 2010

In Page_Load, Request["__EVENTTARGET"] is an empty string.IS there some way I can find out which button triggered the postback before hitting the buttons event handler

View 2 Replies

Web Forms :: How To Identify Control That Caused Postback

Jun 29, 2010

sender.GetType().Name returns me "default.aspx".How do I get the name or identify the control that caused the page postback (Page_Load() event)?

[Code]....

View 9 Replies

Web Forms :: How To Detect Which Control Caused A Postback

Dec 16, 2010

Is there a way to determine which control on a page caused a post back? I need to be able to make the determination since the _DataBound event of a FormView that I'm working with needs function differently based on which control caused the postback.

View 1 Replies

VS 2008 Determine Postback Element?

Oct 1, 2010

Is there a way where I can actually view the name of a post back element? Below code goves me an alert but all it says is "object HTMLSelectElement". In my case it should be DropDownList3 based upon a "selectedindexchanged" event with autoppostback=true.

Code:
var pbControl = null;
pbControl = args.get_postBackElement();
alert(pbControl);
var ExecutingControl = "DropDownList3"
if (ExecutingControl == pbControl) {
alert("DropDownList3 - is the post back element");

View 2 Replies

How To Determine If A Request Is The Result Of A Postback

Aug 5, 2010

I'm implementing a custom page caching solution and I don't want the request to be cached or retrieved from the cache if it's in response to a form submission or some sort of asp.net postback.I'm trying to figure out if the current HttpRequest is a postback. Is there a way of doing this outside the context of a page or other usercontrol? In otherwords if I'm inside an HttpModule I don't have access to this.IsPostBack but I still need to determine if it is in fact a postback.

View 5 Replies

Web Forms :: Determine Which Gridview Control Raised Postback?

May 17, 2010

I have 5 infragistics webdatagrid controls on page, I am using paging and sorting features for the grids. For paging to work for a grid, I need to rebind the grid on every postback in Page_Init or Page_Load event and after that page_indexchanged event gets fired.

Now, when I click on any page number in second grid, I don't want data of other 4grids to be re-bind. I just want to know which grid has done postback and bind that particular grid.

I checked out Request.Forms["__eventargument"] but its value is comma (",").

Consider the scenario for asp.net gridviews and depending upon that I'll get idea to proceed with Infragistics controls.

View 5 Replies

VS 2010 - How To Determine Why Site Takes 5 Minutes Partial Postback

Dec 19, 2013

I have a web application which has rather a lot of controls. I also have several buttons (add, edit, save, cancel). Most of my content page is in an update panel so it does not process the whole page. On form submit I have some javascript code which shows a div 50% opacity and an animated gif to prevent users clicking on the buttons more than once whilst it is processing the data to the server. Here is the javascript / call:

Code:
onsubmit="overlay();"
function overlay() {
el = document.getElementById('overlay');
el.style.display = "inline";
document.getElementById('Image2').src = "../Images/loader.gif";
}
function removeoverlay() {
el = document.getElementById('overlay');
el.style.display = "none";
}

The problem is it the form disables like I want it and the giff animates for about 1.5 seconds but it does not enable the form for a further 4 seconds.

Is there anyway to see what it happpening at this point. If I put some watches in my code behind it runs through less than a second so what else can it be doing.

Also on some laptops the form does not fit vertically so there is a scroll bar. When the div is shown on a submit it does not do the full screen including the scroll area.

View 10 Replies

AJAX :: Determine If User Control Is Contained By The Update Panel That Triggered Async Postback?

Sep 16, 2010

Does anyone know a simple way to determine if a user control is contained in an update panel that was triggered for async postback?

At the moment, the only pseudo logic for this I can think of is?

'Loop through the update panel controls on the page and find the one that is involved in the postback (isInPartialRendering)

'Try to find the user control as a child of the update panel

View 5 Replies

Textbox Always Trigger Postback Event With Autopostback - Stop Postback By Enter Key?

Jun 8, 2010

I have 2 textboxes and a submit button inside a .net composite server control. I tried to only postback when submit button is clicked. I set autopostback = false for both textboxes. But either one still trigger submit button's onclick event by hitting "Enter" inside textbox. How can I stop postback by enter key?

View 2 Replies

C# - On Postback, How To Check Which Control Cause Postback In Page_Init Event?

Jul 4, 2010

On postback, how can I check which control cause postback in Page_Init event.

protected void Page_Init(object sender, EventArgs e)
{
//need to check here which control cause postback?
}

View 5 Replies

Web Forms :: Click Event Does Not Fire On Postback, But Only On Second Postback

Nov 17, 2010

On my page: a Button1, a ListView1, a Panel1 and inside Panel1 an ImageButton1In the ListView1_PreRender-Event the property Panel1.Visible = false or Panel1.Visible = true is set.1. After first loading of the Page Panel.Visible = false ist set in ListView1_PreRender.2. After the postback click on Button1 the criteria for the visibility of Panel1 are evaluated, thus setting in the ListView_PreRender Panel.Visible = true.

View 3 Replies

Web Forms :: Cancel Button PostBack Event During PostBack

Mar 10, 2011

I have a script that runs during the Page_Load() event which checks a database table to make sure that the user is still owns the lock on the page. If they no longer own the lock, I disable all the controls on the page and display an
error message.My thinking was that by disabling all controls during Page_Load() I could prevent any PostBack events from occuring. For example, I have a button on the page called "Save and Quit"

View 2 Replies

.NET Web App Deadlocking - It's Caused By SQL Server Locking

Mar 6, 2010

Our client's web app restarts suddenly at random intervals. For each restart, we've found an entry like this in the Windows Event Log:

Event Type: Warning
Event Source: W3SVC-WP
Event Category: None
Event ID: 2262
Date: 2/21/2010
Time: 1:33:52 PM
[code]...

View 2 Replies

Web Forms :: Validation Caused By Calendar Extender?

Aug 18, 2010

I have a calendar extender for a text box. I have set the text box 'causesvalidation' to false.

I have several other cntrols with required field validators. When I click the popup image for the calendar extender, rhese other required field validators show their error messages.

View 4 Replies

AJAX :: Removing Whitespace Caused By ModalPopup?

Feb 27, 2011

Not too sure if the title is the most appropriate description, but I've noticed at the bottom of my page I have a load of 'whitespace' / emptiness where my panel - that is linked to ModalPopup - is during coding / design. Is there a way of this space not appearing when the page is rendered? Setting the panel's visibility to false gives me all sorts of issues and I don't know where to go now to get rid of this annoying space!

View 2 Replies

Paging One Gridview Caused Other Gridviews To Reload

Oct 1, 2010

I haven't actually dealt with multiple grids on one page in a very long time, so perhaps someone can jog my memory. I have two grids and a treeview in three separate jQuery UI tabs. Every time I page my gridview, which is a custom control inheriting from Gridview, the other tabs refresh.

View 2 Replies

This Error Can Be Caused By A Virtual Directory Not Being Configured As An Application In IIS

Dec 2, 2010

i have developed website in MS framework 2.0 using Visual Studio 2005 Sql Server 2005 and Crystal Report 2008 (Version 12.0.0.549) due to some problem i have formated my pc and reinstalled Visual Studio 2005 Sql Server 2005 and Crystal Report 2008 sp3 (Upper version)on my pc now my website project running on IIS 5. is fine but when i open my website on visual studio 2005 it shows an error as below ...................

101 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

D:NayanAdvance_TestAdvancesystemweb.con

it need registry i think so, Now i did't get this error exactly

View 5 Replies

Web Forms :: ReportViewer: Drillthrough Caused Whole Page Refreshed

Feb 16, 2011

I have a Reportviewer control linked to Report1.rdlc with a matrix with Drillthrough activiated.When I click the "+" buttons to drill through, even I enclosed the control with Penal etc it still caused the whole page refreshed which is annoying. The same Panel code works well on other ASP.net controls on page on running.

View 1 Replies

Security :: Page Caused The Following Exception: System.Net.WebException: The Remote Name Could Not Be Resolved

Feb 3, 2010

I'm using password retrieval to attempt to send their password in an email

The page caused the following exception: System.Net.WebException: The remote name could not be resolved: [URL]

My webconfig file is as follows view plaincopy to clipboardprint?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved