locked
Event Will Not Trigger RRS feed

  • Question

  • Can anyone explain why a C# event will not trigger?  The code is below and is used with ASP. The method DropDownListDisplayModes_SelectedIndexChanged will not fire when the drop down is used.  I am sure the syntax is fine - and the reason is possibly something to do with copying and pasting code into Visual Studio 2005 or typing the code in including method names rather than clicking on a control to create the event.   I have observed things like- if I click on the control the event name is slightly different from what I expect but even after correcting that in code or ASP, the problem continues. (The Drop Down Control name was different in ASP/HTML the name shown in the Drop Down Properties - How can that happen??? It should be impossible.)   I have also checked the method name shows under the control's properties and that is fine too.

    I am not sure if the problem is C# or Visual Studio....and which is the approriate forum for VS issues.

    protected void DropDownListDisplayModes_SelectedIndexChanged(object sender, EventArgs e)

    {

    {

    String selectedMode = DropDownListDisplayModes.SelectedValue;

    Response.Write("If I see this on the Web Page, the event is triggered on drop doen change");

    WebPartDisplayMode mode =

    _wpManager.SupportedDisplayModes[selectedMode];

    if (mode != null)

    {

    _wpManager.DisplayMode = mode;

    }

    }
    }

     


    WhosThat
    Friday, November 14, 2008 12:10 PM

Answers

  • First this is not the SP.NET forum.  But, I didn't see any code that suggested that you actually connected to the event, +=.

    Rudedog   =|^D
    Mark the best replies as answers. "Fooling computers since 1971."
    • Marked as answer by Patrick Grant Saturday, November 15, 2008 10:12 AM
    Friday, November 14, 2008 1:03 PM

All replies

  • First this is not the SP.NET forum.  But, I didn't see any code that suggested that you actually connected to the event, +=.

    Rudedog   =|^D
    Mark the best replies as answers. "Fooling computers since 1971."
    • Marked as answer by Patrick Grant Saturday, November 15, 2008 10:12 AM
    Friday, November 14, 2008 1:03 PM
  • RudeDog thanks for the reply..

    What code would you expect to see to "Connect to the event"?   I had expected if the Drop Down called DropDownListDisplayModes had a value changed on the form, the code would automatically execute.  It does not.  (I hope I am not being too ignorant here....)


    PG001
    Friday, November 14, 2008 5:47 PM