为什么我无法更新面板 [英] Why I Can Not Update The Panel

查看:63
本文介绍了为什么我无法更新面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请任何人都可以帮我解决这个问题,为什么当我点击更新时没有任何事情发生。

我想要的是让人看得更清楚



Please can anyone help me with this code, why when I click update nothing happen .
What i want is to make visible upPanel

protected void Button1_Click(object sender, EventArgs e)
       {
           upPanel.Visible = true;
       }





和asp中的代码





and the code in asp

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <table align="center">
        <tr>       
            <td>
                <asp:Label ID="lblheat" runat="server" Text="Bus List" Font-Size= "X-Large"  

                    ForeColor="#F7990D"></asp:Label>
                    
           <br /> </td>
        </tr>
        <tr><td> </td></tr>
    </table>
 
    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1"  runat="server"></ajaxToolkit:ToolkitScriptManager>
   
    
    <asp:UpdatePanel ID="up1" runat="server"><ContentTemplate> 
 
 <center>
 
     <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 

         AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" 

         BorderStyle="None" BorderWidth="1px" CellPadding="3" 

         DataSourceID="SqlDataSource1" Height="143px" Width="560px" DataKeyNames="ListBusID">
         <FooterStyle BackColor="White" ForeColor="#000066" />
         <RowStyle ForeColor="#000066" />
         <Columns>
             <asp:TemplateField HeaderText="Select One">
             <itemtemplate>
                                              <input name="MyRadioButton" type="radio" 

                                                        value='<%# Eval("ListBusID")%>' />
                                            </itemtemplate>
         </asp:TemplateField>

             <asp:BoundField DataField="ListBusID" HeaderText="ListBusID" SortExpression="ListBusID" ReadOnly="True" />
             <asp:BoundField DataField="BusID" HeaderText="BusID" 

                 SortExpression="BusID" />
             <asp:BoundField DataField="RouteID" HeaderText="RouteID" 

                 SortExpression="RouteID" />
             <asp:BoundField DataField="Departure" HeaderText="Departure" SortExpression="Departure" />
              <asp:BoundField DataField="Price" HeaderText="Price" 

                 SortExpression="Price" />
             <asp:CheckBoxField DataField="Status" HeaderText="Status" SortExpression="Status" />
         </Columns>

         
         <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
         <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
     </asp:GridView>


     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BazaConnectionString2 %>" 

         SelectCommand="SELECT * FROM [ListBus]">
     </asp:SqlDataSource>

     <br />
     <asp:Button ID="Button1" runat="server" Text="Update" OnClick="Button1_Click" />
       
     <asp:Button ID="Button2" runat="server" Text="Delete" />
     <br />

</center>
</ContentTemplate></asp:UpdatePanel> 
</asp:Content>


<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">

    <asp:Panel ID="upPanel" runat="server" Visible="false">
      <center>
      <table>
        <tr>
            <td>BusID</td>
            <td><asp:TextBox ID="txtBus" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>RouteID</td>
            <td><asp:TextBox ID="txtRoute" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>Departure</td>
            <td><asp:TextBox ID="txtDeparture" runat="server"></asp:TextBox>
                <ajaxToolkit:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDeparture"  runat="server"></ajaxToolkit:CalendarExtender>  
            </td>
        </tr>
        <tr>
            <td>Price</td>
            <td><asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            
            <td><asp:ImageButton ID="Submit" runat="server" ImageUrl="~/Images/btn_go.gif" OnClick="Submit_Click" /></td>
            <td><asp:Label ID="lblUpdate" runat="server" Text=""></asp:Label></td>
        </tr>
      </table>
      </center>
    </asp:Panel>

</asp:Content>

推荐答案

ConnectionStrings:BazaConnectionString2 %>\"

SelectCommand=\"SELECT * FROM [ListBus]\">
</asp:SqlDataSource>

<br />
<asp:Button ID=\"Button1\" runat=\"server\" Text=\"Update\" OnClick=\"Button1_Click\" />
  
<asp:Button ID=\"Button2\" runat=\"server\" Text=\"Delete\" />
<br />

</center>
</ContentTemplate></asp:UpdatePanel>
</asp:Content>


<asp:Content ID=\"Content4\" ContentPlaceHolderID=\"ContentPlaceHolder3\" Runat=\"Server\">

<asp:Panel ID=\"upPanel\" runat=\"server\" Visible=\"false\">
<center>
<table>
<tr>
<td>BusID</td>
<td><asp:TextBox ID=\"txtBus\" runat=\"server\"></asp:TextBox></td>
</tr>
<tr>
<td>
RouteID</td>
<td><asp:TextBox ID=\"txtRoute\" runat=\"server\"></asp:TextBox></td>
</tr>
<tr>
<td>Departure</td>
<td><asp:TextBox ID=\"txtDeparture\" runat=\" server\"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID=\"CalendarExtender1\" TargetControlID=\"txtDeparture\" runat=\"server\"></ajaxToolkit:CalendarEx tender>
</td>
</tr>
<tr>
<td>Price</td>
<td><asp:TextBox ID=\"txtPrice\" runat=\"server\"></asp:TextBox>
</td>
</tr>
<tr>

<td>&l t;asp:ImageButton ID=\"Submit\" runat=\"server\" ImageUrl=\"~/Images/btn_go.gif\" OnClick=\"Submit_Click\" /></td>
<td><asp:Label ID=\"lblUpdate\" runat=\"server\" Text=\"\"></asp:Label></td>
</tr>
</table>
</center>
</asp:Panel>

</asp:Content>
ConnectionStrings:BazaConnectionString2 %>" SelectCommand="SELECT * FROM [ListBus]"> </asp:SqlDataSource> <br /> <asp:Button ID="Button1" runat="server" Text="Update" OnClick="Button1_Click" />    <asp:Button ID="Button2" runat="server" Text="Delete" /> <br /> </center> </ContentTemplate></asp:UpdatePanel> </asp:Content> <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server"> <asp:Panel ID="upPanel" runat="server" Visible="false"> <center> <table> <tr> <td>BusID</td> <td><asp:TextBox ID="txtBus" runat="server"></asp:TextBox></td> </tr> <tr> <td>RouteID</td> <td><asp:TextBox ID="txtRoute" runat="server"></asp:TextBox></td> </tr> <tr> <td>Departure</td> <td><asp:TextBox ID="txtDeparture" runat="server"></asp:TextBox> <ajaxToolkit:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDeparture" runat="server"></ajaxToolkit:CalendarExtender> </td> </tr> <tr> <td>Price</td> <td><asp:TextBox ID="txtPrice" runat="server"></asp:TextBox> </td> </tr> <tr> <td><asp:ImageButton ID="Submit" runat="server" ImageUrl="~/Images/btn_go.gif" OnClick="Submit_Click" /></td> <td><asp:Label ID="lblUpdate" runat="server" Text=""></asp:Label></td> </tr> </table> </center> </asp:Panel> </asp:Content>


Because you’re doing it on the server side (and to view your panel you have to reload your page). You have to use JavaScript code on client side to make \"instant\" changes on a web page. I would recommend jQuery to simplify your task.
Because you're doing it on the server side (and to view your panel you have to reload your page). You have to use JavaScript code on client side to make "instant" changes on a web page. I would recommend jQuery to simplify your task.


Thanks man but I have the solution now, I’ve just change Panel to UpdatePanel and it works
Thanks man but I have the solution now, I've just change Panel to UpdatePanel and it works


这篇关于为什么我无法更新面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆