Click here to Skip to main content
15,904,153 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: column selection of GridView Pin
Rutvik Dave21-Jan-10 9:45
professionalRutvik Dave21-Jan-10 9:45 
AnswerRe: column selection of GridView Pin
kadaoui el mehdi21-Jan-10 8:14
kadaoui el mehdi21-Jan-10 8:14 
Questionprotect excel sheet by password using OWC in C# - Exception from HRESULT: 0xE0040059 - Urgent Pin
nishithrajn21-Jan-10 4:29
nishithrajn21-Jan-10 4:29 
QuestionGrid view Paging Issue Pin
Amit Patel198521-Jan-10 3:26
Amit Patel198521-Jan-10 3:26 
GeneralRe: Grid view Paging Issue Pin
Pranay Rana21-Jan-10 4:33
professionalPranay Rana21-Jan-10 4:33 
AnswerRe: Grid view Paging Issue Pin
Rutvik Dave21-Jan-10 7:44
professionalRutvik Dave21-Jan-10 7:44 
AnswerRe: Grid view Paging Issue Pin
Amit Patel198521-Jan-10 18:58
Amit Patel198521-Jan-10 18:58 
QuestionDynamically Changing EventHandlers in Web page Pin
moon_stick21-Jan-10 3:13
moon_stick21-Jan-10 3:13 
I've already posted this on StackOverflow[^] but haven't seen much traffic yet...

I've got a web form (set in a master page) and want to check to see if the page has any changes before exiting (either by success or redirect). If any changes have been made, a dialog is displayed and the user can click ok or cancel.

I've created a panel to act as a dialog box (change z-layer, and apply shading and opacity to background) but my problem is in handling the click events from the buttons on the dialog. For a given exit scenario, I want to do something like:

protected void btnWelcomePage_Click(object sender, ImageClickEventArgs e)
{
    if (this.HasChanges())
    {
        lblDialogTitle.Text = "Confirm Exit";
        lblDialogMessage.Text = "Are you sure? Click OK to continue and lose any data entered";
        ClearEventHandlers(btnDialogOK);
        btnDialogOK_Click.Click += new EventHandler(btnDialogOK_Click);
        ClearEventHandlers(btDialogCancel);
        btnDialogCancel_Click += new EventHandler(btnDialogCancel_Click);
        pnlDialog.Visible = true;
    }
    else
    {
        Response.Redirect("~/WelcomePage.aspx");
    }
}


where the event handler for the buttons will do the appropriate work to hide the dialog and redirect if required.

My problem is that the EventHandler doesn't appear to bind between postbacks - setting a breakpoint in the Click event handler doesn't do anything; the page does an empty postback.

I assumed that the postback trashes the EventHandlers so I enabled ViewState on the buttons but to no avail. Can anyone suggest a model for handling this type of change? I've been searching through google but everything appears to relate to the dynamic creation of controls rather than the dynamic assignment of EventHandlers.

Thanks in advance

Dave

It definitely isn't definatley

AnswerRe: Dynamically Changing EventHandlers in Web page Pin
Pranay Rana21-Jan-10 4:27
professionalPranay Rana21-Jan-10 4:27 
AnswerRe: Dynamically Changing EventHandlers in Web page Pin
kadaoui el mehdi21-Jan-10 7:58
kadaoui el mehdi21-Jan-10 7:58 
QuestionThread End Pin
i gr821-Jan-10 3:02
i gr821-Jan-10 3:02 
AnswerRe: Thread End Pin
J a a n s21-Jan-10 3:07
professionalJ a a n s21-Jan-10 3:07 
AnswerRe: Thread End Pin
Amit Patel198521-Jan-10 3:17
Amit Patel198521-Jan-10 3:17 
GeneralRe: Thread End Pin
i gr821-Jan-10 3:29
i gr821-Jan-10 3:29 
QuestionAlternate of File upload control Pin
santosh_kum20-Jan-10 23:02
santosh_kum20-Jan-10 23:02 
AnswerRe: Alternate of File upload control Pin
nainakarri21-Jan-10 1:53
nainakarri21-Jan-10 1:53 
QuestionWeb service call to get Yahoomail contacts Pin
kokilaB20-Jan-10 21:27
kokilaB20-Jan-10 21:27 
QuestionStackedBar100 Pin
yesu prakash20-Jan-10 20:35
yesu prakash20-Jan-10 20:35 
QuestionXLS to XSL:FO Pin
Venkat Eswaran20-Jan-10 20:07
Venkat Eswaran20-Jan-10 20:07 
QuestionProblem triangular calling c#->javascript->c# on single click of search button [modified] Pin
Vishnu Narayan Mishra20-Jan-10 19:43
Vishnu Narayan Mishra20-Jan-10 19:43 
AnswerRe: Problem triangular calling c#->javascript->c# on single click of search button Pin
Brij20-Jan-10 20:10
mentorBrij20-Jan-10 20:10 
AnswerRe: Problem triangular calling c#->javascript->c# on single click of search button Pin
Pranay Rana20-Jan-10 20:49
professionalPranay Rana20-Jan-10 20:49 
QuestiongridView Pin
jojoba201020-Jan-10 19:35
jojoba201020-Jan-10 19:35 
AnswerRe: gridView Pin
Brij20-Jan-10 20:22
mentorBrij20-Jan-10 20:22 
AnswerRe: gridView Pin
Anurag Gandhi20-Jan-10 22:27
professionalAnurag Gandhi20-Jan-10 22:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.