我怎样才能获得asp:Panel与asp:RadioButtonList一起正常工作? [英] How do I can get asp:Panel to work properly with asp:RadioButtonList?

查看:45
本文介绍了我怎样才能获得asp:Panel与asp:RadioButtonList一起正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我很长时间遇到这个问题并且搜索并尝试了许多不同的解决方案,但没有任何工作正常......我有这个:



Hey guys, I've having trouble with this for a long while and searching and trying many many different solutions, but nothing worked correctly... I have this:

<asp:RadioButtonList ID="accomodation" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" Width="500px">
                <asp:ListItem Text="Not Required" Value="Not Required"></asp:ListItem>
                <asp:ListItem Text="Required" Value="Required"></asp:ListItem>
            </asp:RadioButtonList>

            <asp:Panel ID="PanelAccommodation" runat="server">
                <p>
                    Number of nights (*):
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="numberOfNights" ForeColor="red" ErrorMessage="<- Required"></asp:RequiredFieldValidator>
                </p>
                <asp:TextBox ID="numberOfNights" runat="server" Width="50px"></asp:TextBox>

                <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="numberOfNights"
                    FilterType="Numbers"  runat="server">
                </ajaxToolkit:FilteredTextBoxExtender>

                <p>Preferred Hotel:</p>
                <asp:TextBox ID="preferredHotel" runat="server" Width="450px"></asp:TextBox>

                <p>Preferred Hotel URL:</p>
                <asp:TextBox ID="preferredHotelURL" runat="server" Width="450px"></asp:TextBox>

            </asp:Panel>





我想要的是面板关闭时页面加载,选择必需时打开,如果/选择不需要则关闭...我也不想使用AutoPostBack,因为它会回到页面顶部...请帮忙!



and what I want is for the panel to be closed when page is loaded, open when "Required" is selected and close if/when "Not Required" is selected... also I don't want to use AutoPostBack because it goes back to the top of the page... please help!

推荐答案

有两种方法可以做到这一点

1.使用UpdatePanel,这样当你没有回到页面顶部时AutoPostBack

2.使用JavaScript并使面板显示:none(隐藏)和display:block(shows)
There are two ways of doing this
1. Use UpdatePanel so that it does not go back to top of the page when you AutoPostBack
2. Use JavaScript and make the panel display:none (hides) and display:block (shows)


Guys I was also struggling with this problem (Using jQuery to hide/show a Panel when user clicks on a value on the RadioButtonList) and searched many posts and found no answer but I was able to make it work here's how I did...

My code is as follows:

    <div>
                <p class="space">3.2. ACCOMMODATION (*)</p>

                <asp:RadioButtonList ID="accomodation" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" Width="500px">
                    <asp:ListItem Text="Not Required" Value="Not Required"></asp:ListItem>
                    <asp:ListItem Text="Required" Value="Required"></asp:ListItem>
                </asp:RadioButtonList>

                <asp:Panel ID="PanelAccommodation" runat="server">
                    <p>
                        Number of nights (*):
                         <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="numberOfNights" ForeColor="red" ErrorMessage="<- Required"></asp:RequiredFieldValidator>
                    </p>
                    <asp:TextBox ID="numberOfNights" runat="server" Width="50px"></asp:TextBox>

                    <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="numberOfNights"

                        FilterType="Numbers" runat="server">
                    </ajaxToolkit:FilteredTextBoxExtender>

                    <p>Preferred Hotel:</p>
                    <asp:TextBox ID="preferredHotel" runat="server" Width="450px"></asp:TextBox>

                    <p>Preferred Hotel URL:</p>
                    <asp:TextBox ID="preferredHotelURL" runat="server" Width="450px"></asp:TextBox>
                </asp:Panel>
            </div>

and the jquery function I used:

    <pre lang="Javascript">


(document).ready(function(){
(document).ready(function () {


这篇关于我怎样才能获得asp:Panel与asp:RadioButtonList一起正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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