.NET技术问题,高分求助!

lzqlrr 2007-11-15 08:30:51
我遇到的问题是这样的
我的系统首页为Default.aspx,页面代码如下;
*********************************************
<%@ Page Language="C#" MasterPageFile="~\Main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Default.aspx页面所用的master母板页为Main.master,页面代码如下:
**************************************************************
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Main.master.cs" Inherits="Main" %>
<%@ Register Src="topDav.ascx" TagName="myTop" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Main Page</title>
<link href="radar.css" rel="stylesheet" type="text/css" />
<link href="radar.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="head" runat="server">
<uc1:myTop id="myTop1" runat="server">
</uc1:myTop>
</asp:contentplaceholder>

<asp:contentplaceholder id="mainContent" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
*************************************
其中母板页上所应用的自定义控件为:topDav.ascx,页面代码如下:
***********************************
<asp:Label ID="reminderLabel" runat="server" Text="Reminder:" Visible="false"></asp:Label>

现在我想在Default.aspx页面上对topDav.ascx中的reminderLabel进行操作,将其Visible改为true,请问我应该在Default.aspx.cs里面写什么样的代码才可以实现这个功能?因为我不知道在Default.aspx页面上如何获取master page中自定义控件中控件的属性。
希望大家帮帮忙,给我点思路或是方法,在下感激不尽!~
...全文
94 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzqlrr 2007-11-18
  • 打赏
  • 举报
回复
谢谢大家,问题已经解决啊!~
我是这样解决的:
首先在topDav.ascx.cs中定义一个方法:
public void controlLabelVisible()
{
this.reminderLabel = true;
}
然后在main.master.cs中定义一个公有方法来调用controlLabelVisible()
public void controlTop()
{
myTop1.controlLabelVisible();
}
最后在default.aspx.cs中调用controlTop()
Main mp= new Main();
mp.controlTop();
这样就可以满足我的需求了,不过还是要感谢大家的建议,散分~
sunlovesea 2007-11-17
  • 打赏
  • 举报
回复
仅供参考:使用母板页面下设置整个文本框为只读
-------------------------------------------------------------------

protected void Button1_Click(object sender, EventArgs e)
{
ContentPlaceHolder c = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
foreach (Control tb in c.Controls)
{
if (tb.GetType() == typeof(TextBox))
{
((TextBox)tb).ReadOnly = true;
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
ContentPlaceHolder c = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
foreach (Control tb in c.Controls)
{
if (tb.GetType() == typeof(TextBox))
{
((TextBox)tb).ReadOnly = false;
}
}
}
qq22345111 2007-11-17
  • 打赏
  • 举报
回复
如果是使用的 "母版"
那完全不用这样。直接去母版页面改变属性就可以了!
雄牛 2007-11-17
  • 打赏
  • 举报
回复


漂过~~~~~~~~~~~~~~~~~~~~~

友情UP.....



黑暗行动 2007-11-15
  • 打赏
  • 举报
回复
public partial class UserControl_head : System.Web.UI.UserControl
{
public string imgPath;
protected void Page_Load(object sender, EventArgs e)
{

}

public string Path
{
get
{
return imgPath;
}
set
{
imgPath = value;
}

}
}

<uc:head ID="head1" runat="server" Path="images"/>

public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.head1.path="########"; }
}
vefo 2007-11-15
  • 打赏
  • 举报
回复
vicqqq

topDav.ascx写个属性
vicqqq 2007-11-15
  • 打赏
  • 举报
回复
topDav.ascx写个属性

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧