调用用户控件中的方法 我有个用户控件Mypage.ascx,用户控件Mypage.ascx.cs中有个方法 public void initpage() 我现在想在Default.aspx页面调用initpage()方法,怎么办 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 aspx:<%@ Register TagPrefix="aspx" TagName="mypage" Src="~/mypage.ascx" %><aspx:mypage runat="server" ID="ppMyPage" />aspx.csppMyPage.initpage(); 在你的Code-Behind文件里要引用你的用户控件的Namespace才可以。 我的default.aspx的页面如下<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register TagPrefix="aspx" TagName="mypage" Src="mypage.ascx" %> <!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>无标题页</title></head><body> <form id="form1" runat="server"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><asp:DataList ID="DataList1" runat="server" Width="533px"><ItemTemplate><table cellpadding="0" cellspacing="0" border="0" width="99%"><tr ><td style="width:20%">测试</td><td style="width:80%"><%#Eval("name") %></td></tr></table></ItemTemplate></asp:DataList></td></tr><tr><td><aspx:mypage runat="server" ID="ppMyPage" /> </td></tr></table> </form></body></html>default.aspx.cs页面的代码:ppMyPage.只有几个tostring,equal之类的没有ppMyPage.initpage(); 熟悉只读感应式读卡器的朋友请进 关于图片嵌入到exe的问题 所有的USB接口都用不了? html中表的单元的坐标值问题:我定义了一个html的Table1,如何获得这个Table1某一个单元的坐标值啊 怎样让LinkLable不会得到焦点? COM 与.net framework 在程序通讯上的区别? Eyeshot Ultimate 7.0准确定位的问题 VS2012 源代码管理没有svn 關於ADRead 怎样学好正则表达式? C#操作WORD设置底纹无效 一个xpath查询的问题
aspx.csppMyPage.initpage();
在你的Code-Behind文件里要引用你的用户控件的Namespace才可以。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register TagPrefix="aspx" TagName="mypage" Src="mypage.ascx" %>
<!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>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<asp:DataList ID="DataList1" runat="server" Width="533px">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" width="99%">
<tr >
<td style="width:20%">测试</td>
<td style="width:80%"><%#Eval("name") %></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td>
<aspx:mypage runat="server" ID="ppMyPage" />
</td>
</tr>
</table>
</form>
</body>
</html>
default.aspx.cs页面的代码:ppMyPage.只有几个tostring,equal之类的没有ppMyPage.initpage();