locked
Why fired OnSelectedIndexChanged event, it is lost focus? RRS feed

  • Question

  • User1741069310 posted

    Hi,

    I want to solve, after OnSelectedIndexChanged DDLoEonChange fired, the layout is changed?

    <asp:View ID="LoEAdmin" runat="server">
    <form id="LoEAdminForm" >
    <table>
    <tr>
    <td>LoEAdminForm</td>
    <td colspan="2">
    <asp:DropDownList id="DDLoESelect" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDLoEonChange" ></asp:DropDownList>

    <select id="LoESelect" name="LoESelect" runat="server" >
    </select>
    </td>
    </tr>
    <tr>
    <td>Description : </td><td><input id="LoEDescription" type="text" name="LoEDescription" runat="server" /></td>
    <td><asp:RequiredFieldValidator runat="server" ID="rLoEDescription" ControlToValidate="LoEDescription" ErrorMessage="LoEDescription file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
    <td>Remarks : </td><td><input id="LoERemarks" type="text" name="LoERemarks" runat="server" /></td><td><asp:RequiredFieldValidator runat="server" ID="rLoERemarks" ControlToValidate="LoERemarks" ErrorMessage="LoERemarks file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
    <td>Clean Version : </td><td><asp:FileUpload ID="LoEClean_Version" runat="server" /></td><td><asp:RequiredFieldValidator runat="server" ID="rLoEClean_Version" ControlToValidate="LoEClean_Version" ErrorMessage="LoEClean_Version file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr><td>Track Change : </td><td><asp:FileUpload ID="LoETrack_Change" runat="server" /></td><td><asp:RequiredFieldValidator runat="server" ID="rLoETrack_Change" ControlToValidate="LoETrack_Change" ErrorMessage="LoETrack_Change file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr><td colspan="3"><asp:Button ID="btnLoEUpload" runat="server" Text="Upload" OnClick="UploadLoEAction" /></td></tr>

    </table>
    </form>
    </asp:View>

    Thanks

    Francis SZE

    Wednesday, June 13, 2018 2:30 AM

Answers

  • User1724605321 posted

    Hi fsze88,

    I can't reproduce your error , please provide your code behind event and explain more . General we can set the ActioViewIndex  which is used to get an Index of your View. Please try to use :

     MultiView1.ActiveViewIndex = YourIndex;

    For exmaple , your current view is in the second one of MultiView , then set ActiveViewIndex to 1.

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 13, 2018 7:38 AM
  • User409696431 posted

    Use the SetActiveView method in your dropdown function.   Since I don't know the id of your Multiview (you aren't showing all your markup/code), I can't tell you exactly what to use, but it will be

    YourMultiViewID.SetActiveView(LoEAdmin);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 13, 2018 7:38 AM

All replies

  • User409696431 posted

    What do you mean the layout is changed?   That is a different question from your title, which is about focus being lost.

    You have only shown us a snippet of code.   It appears you are using a Multiview control, and we have no idea what other views you have, or what code you have wired up to transition between views.

    Wednesday, June 13, 2018 5:17 AM
  • User1741069310 posted

    on DroptDownList after SelectedIndexChanged event fired and call void DDLoEonChange

    <asp:DropDownList id="DDLoESelect" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDLoEonChange" ></asp:DropDownList>

    the web page become blank

    Wednesday, June 13, 2018 6:14 AM
  • User632428103 posted

    Hello all,

    Ok course it's a post back because the dropdownlist has autpostback true => when you change a value inside the ENTIRE page is REFRESH ...

    what do you want to do exactly ? if you don't want to refresh the entire page :

    • add an update panel
    • delete the method onselectedindexchanged and autopostback and add a javascript function

    tell us what do you need exactly ?

    Wednesday, June 13, 2018 6:49 AM
  • User1741069310 posted

    a way to go back the view after run  DDLoEonChange function?

    <asp:View ID="LoEAdmin" runat="server">
    <form id="LoEAdminForm" >
    <table>
    <tr>
    <td>LoEAdminForm</td>
    <td colspan="2">
    <asp:DropDownList id="DDLoESelect" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDLoEonChange" ></asp:DropDownList>

    <select id="LoESelect" name="LoESelect" runat="server" >
    </select>
    </td>
    </tr>
    <tr>
    <td>Description : </td><td><input id="LoEDescription" type="text" name="LoEDescription" runat="server" /></td>
    <td><asp:RequiredFieldValidator runat="server" ID="rLoEDescription" ControlToValidate="LoEDescription" ErrorMessage="LoEDescription file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
    <td>Remarks : </td><td><input id="LoERemarks" type="text" name="LoERemarks" runat="server" /></td><td><asp:RequiredFieldValidator runat="server" ID="rLoERemarks" ControlToValidate="LoERemarks" ErrorMessage="LoERemarks file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
    <td>Clean Version : </td><td><asp:FileUpload ID="LoEClean_Version" runat="server" /></td><td><asp:RequiredFieldValidator runat="server" ID="rLoEClean_Version" ControlToValidate="LoEClean_Version" ErrorMessage="LoEClean_Version file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr><td>Track Change : </td><td><asp:FileUpload ID="LoETrack_Change" runat="server" /></td><td><asp:RequiredFieldValidator runat="server" ID="rLoETrack_Change" ControlToValidate="LoETrack_Change" ErrorMessage="LoETrack_Change file is empty"></asp:RequiredFieldValidator></td>
    </tr>
    <tr><td colspan="3"><asp:Button ID="btnLoEUpload" runat="server" Text="Upload" OnClick="UploadLoEAction" /></td></tr>

    </table>
    </form>
    </asp:View>

    Wednesday, June 13, 2018 7:06 AM
  • User1724605321 posted

    Hi fsze88,

    I can't reproduce your error , please provide your code behind event and explain more . General we can set the ActioViewIndex  which is used to get an Index of your View. Please try to use :

     MultiView1.ActiveViewIndex = YourIndex;

    For exmaple , your current view is in the second one of MultiView , then set ActiveViewIndex to 1.

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 13, 2018 7:38 AM
  • User409696431 posted

    Use the SetActiveView method in your dropdown function.   Since I don't know the id of your Multiview (you aren't showing all your markup/code), I can't tell you exactly what to use, but it will be

    YourMultiViewID.SetActiveView(LoEAdmin);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 13, 2018 7:38 AM