Determining The Control That Caused A PostBack
Jul 16, 2010can I retrieve the name that caused a postback? (VB.NET)
View 5 Repliescan I retrieve the name that caused a postback? (VB.NET)
View 5 RepliesIn 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 Repliessender.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]....
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 RepliesCurrently 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.
i'm using a gridview and has a column of checkbox that is within a template field.
I want to do it in C# but I only found this code in VB
[Code]....
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?
iam using the Jquery Uframe with asp.net project.Iam getting a postback problem here.
In side the uframe ,button control getting postback the page even the client side method call also.
i tried with the Html button Control also by setting the type="submit" ,iam facing the same problem.
And I got very limited reference about the uframe(codeflex,codeProject).
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?
}
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.
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.
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]...
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.
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 RepliesI 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 RepliesI am currently developing a site for my OJT.I have created a login form for my site now I got confused on what to do with this one. I need to identify if the user has been log-in or log-out As the user inputted the exact username and password it will go to this line of codes in which will identity if the user has bees signout or not.
HttpCookie cookie = new HttpCookie("isLog");
cookie.Value = "1";
DateTime dtNow = DateTime.Now;
TimeSpan tsMinute = new TimeSpan(1, 1, 0, 0);
cookie.Expires = dtNow + tsMinute;
Response.Cookies.Add(cookie);
Response.Redirect("manageService.aspx");
And I have this function to determine if the user has been log-in or log-out.
protected Boolean isLog()
{
//String strCookieName = Request.QueryString["cookie"].ToString();
//Grab the cookie
HttpCookie cookie = Request.Cookies["isLog"];
String tmp = cookie.Value.ToString();
return (tmp != null);
}
Now, my problem here is that even though I inputted the correct username and password after reloading the page it will still asked for the user name and password(sends me to the login page). I already set a value for the "isLog" cookie but still it return a wrong info.
I have a textbox where the enduser will type either a customer number (int) or a lastname, firstname and press a submit button. I need to programatically determine whether the text field of the textbox can be parsed as an int - and if so, process methodThis or if it is a string, process methodThat.
[Code]....
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
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.
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 RepliesI am unsure how to quickly check a set of returned values for a specific value. Given the following:
[Code]....
I then want to check all the returns values in locs for a specific value. I know I could build a foreach loop that would walk through every return data value in locs to see if it matched, but I was hoping to use something simpler.
[Code]....
I tried to search for this already as I am sure it has been asked before, but I apparently lack the proper search keywords.
I have wizards in my app and when the user clicks one, the first thing I check is the "progress status" of the wizard for that user in case he/she has already started the process but never completed it. However, there's always a possibility that he/she might have completed 2 steps in a 5 step wizard.
I read the progress data into a simple List<WizardProgress> which looks like this:
StepID - CompletionDate
1 -- 12/1/2010 18:52:00
2 -- 12/2/2010 18:53:00
3 -- NULL
4 -- NULL
5 -- NULL
What is the best way for me to find the last completed step? It's easy enough to do a foreach but was wondering if there was a better way to do it.
I came upon an interesting discussion with my team around the use of HttpRequest.UrlReferrer and wanted to solicit feedback from the community. According to the W3C spec:
The Referer[sic] request-header field allows the client to specify, for the server's benefit, the address (URI) of the resource from which the Request-URI was obtained (the"referrer", although the header field is misspelled.) The Referer request-header allows a server to generate lists of back-links to resources for interest, logging, optimized caching, etc. It also allows obsolete or mistyped links to be traced for maintenance. The Referer field MUST NOT be sent if the Request-URI was obtained from a source that does not have its own URI, such as input from the user keyboard.as input from the user keyboard.
The Request.UrlReferrer object does the work of converting referral strings that contain well formed URIs to an object with properties on every request. According to our logs there are requests that come in that contain invalid data in the referral such as:
localhost
app:/BeamBackTest.swf
app:/multtiple.swf
app:/AFriendFeed.swf
ALToolBar
app:/index.html
mhtml:file://C:Documents+and+SettingsUserDesktoporacleWhat+is+a+View+in+Oracle+-+Stack+Overflow.mht
Using Request.UrlReferrer would mean the above cases would be NULL. Is it better to discard the invalid data based on the W3C spec by using Request.UrlReferrer or preserve it by using Request.ServerVariables["HTTP_REFERER"] even though the data may be interesting, but potentially useless.
dear all. First and foremost the format of my dates are as follows (MM/DD/YYYY)
I have date 1 as 02/01/2007
I have date 2 as 02/07/2009
I would like to determine the number of days between those dates.
I need to test to if the div is toggled to hide. if it is not hidden I want to toggle it again ( slides left ). when they click the view report button on the Report Viewer control.
But I'm not sure how to find it's toggle values ( whether it's hidden )? ideas?
toggle click function
[Code]....
tried this and doesnt work
[Code]....