Marco Dinatsoli
Marco Dinatsoli

Reputation: 10570

update panel is not working on asp.net code

This is my c# code behind

protected void callDispositionChanged(object sender, EventArgs e)
{
    var dropDown = (DropDownList)ListView1.FindControl("callDispositionSelector");
    var visitID = (TextBox)ListView1.FindControl("visitID");
    if (dropDown != null)
    {
        Response.Write(dropDown.SelectedValue + "ssssssssss");
        visitID.Text = dropDown.SelectedValue;
    }
    else
    {
        visitID.Text = "ffffff";
        Response.Write("FFFFFFFFFFFFFFFF");
    }               
}

this is my asp code

<asp:UpdatePanel ID="UpdatePanel3" UpdateMode="Conditional" runat="server">
                        <ContentTemplate>
                        <tr class="footer" runat="server">
                            <td colspan="4" runat="server">* By VoiceMpower
                               <asp:DropDownList AutoPostBack="true" runat="server"  ID="callDispositionSelector" OnSelectedIndexChanged="callDispositionChanged" clientidmode="Static">
                                   <asp:ListItem Value="-1">Select Disposition Reason</asp:ListItem>
                                   <asp:ListItem Value="1">Reservation</asp:ListItem>
                                   <asp:ListItem Value="2">Change of Reservation</asp:ListItem>
                                   <asp:ListItem Value="3">Cancellation</asp:ListItem>
                                   <asp:ListItem Value="4">Wait List</asp:ListItem>
                                   <asp:ListItem Value="5">Other</asp:ListItem>
                               </asp:DropDownList>
                                <asp:TextBox runat="server" ID="visitID" clientidmode="Static"></asp:TextBox>
                            </td>
                        </tr>
                         </ContentTemplate>
                    </asp:UpdatePanel>

when I change the value of the select, the function is executed, but the results (the post back page) has the select in the devaul vaule.

note

i already have

<asp:ScriptManager ID="ScriptManager2" runat="server" />

note 3

that asp code exist in item template in asp.listview

Note2

I can't debug the project because the database on the server and I am not allowed to make a link to it. So each time i develop a functoin, I go and deploy the website on the server and test it. So please let your answers without making break points and something like that. thanks in advance

Upvotes: 0

Views: 1085

Answers (1)

Amit Joki
Amit Joki

Reputation: 59232

You are using Conditional Mode which means, the update panel will not work, unless the event is triggered.

Remove that.

 <asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
                <tr class="footer" runat="server">
                    <td colspan="4" runat="server">* By VoiceMpower
                           <asp:DropDownList AutoPostBack="true" runat="server" ID="callDispositionSelector" OnSelectedIndexChanged="callDispositionChanged" ClientIDMode="Static">
                               <asp:ListItem Value="-1">Select Disposition Reason</asp:ListItem>
                               <asp:ListItem Value="1">Reservation</asp:ListItem>
                               <asp:ListItem Value="2">Change of Reservation</asp:ListItem>
                               <asp:ListItem Value="3">Cancellation</asp:ListItem>
                               <asp:ListItem Value="4">Wait List</asp:ListItem>
                               <asp:ListItem Value="5">Other</asp:ListItem>
                           </asp:DropDownList>
                        <asp:TextBox runat="server" ID="visitID" ClientIDMode="Static"></asp:TextBox>
                    </td>
                </tr>
            </ContentTemplate>
        </asp:UpdatePanel>

Upvotes: 1

Related Questions