本文介绍了无法在内容占位符页面中显示控件RBL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
拥有母版页和内容占位符页面。在占位符页面中,我有Checkbox。
如果勾选复选框,我希望显示RadioButtonList6。在下面的代码中,它不会发生在母版页的这种情况下。如果没有母版页运行,相同的代码工作正常。如何解决这个问题?
In have a master page and a content placeholder page. In the placeholder page, I have Checkbox.
If I tick the checkbox I want the RadioButtonList6 to be displayed. In following code it is not happenning in such circumstance with a master page. If run without a master page, this same code works fine. How to rectify this?
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="checkboxtest6.aspx.cs" Inherits="checkboxtest6" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:UpdatePanel ID="UP1" runat="server" >
<ContentTemplate>
<asp:TextBox ID="MyFirstTextBox" runat="server"></asp:TextBox>
<asp:TextBox ID="MySecondTextBox" runat="server"></asp:TextBox>
<asp:CheckBox ID="MyCheckBox" runat="server" style=" margin-left:3px; "/>
<asp:RadioButtonList ID="RBL6" runat="server" OnSelectedIndexChanged="RBL6_OSIC"
RepeatDirection="Vertical" AutoPostBack="true"
style="" >
<asp:ListItem>Deliver at the above address</asp:ListItem>
<asp:ListItem>Deliver at a different address</asp:ListItem>
</asp:RadioButtonList>
<script type="text/javascript" language="javascript">
function ShowRBL6() {
RBL6.style.display ="";
}
</script>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
public partial class checkboxtest6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.RBL6.Style.Add("display", "none");
this.MyCheckBox.Attributes.Add("onClick", "ShowRBL6()");
}
protected void RBL6_OSIC(object sender, EventArgs e)// delivery options when 'send to guest' selected
{
}
推荐答案
function ShowRBL6() {
if (document.getElementById('<% = MyCheckBox.ClientID %>').checked == true)
document.getElementById('<% = RBL6.ClientID %>').style.display = "block";
else
document.getElementById('<% = RBL6.ClientID %>').style.display = "none";
}
因此下一次点击也将用于取消检查将被处理。
so the next click will be also for unchecking will be handled.
这篇关于无法在内容占位符页面中显示控件RBL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!