a.aspx
有个控件
<uc1:CityPort ID="CityPort1" runat="server" />控件代码
CityPort.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CityPort.ascx.cs" Inherits="CityPort" %>
<table width="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width:130px">
<asp:TextBox ID="tbPort" runat="server" Width="130px"></asp:TextBox>
</td>
<td style="width:20px" valign="bottom">
<img src="images/button_search.gif" 20px" width="18px" id="IMG1" language="javascript" onclick="javascript:window.showModalDialog('port.aspx',window,'status:Modeless;edge:sunken;unadorned:no;scroll=no;resizable:no;dialogLeft:300;dialogtop:200;help:no;dialogwidth:400px;dialogheight:240px');void(0);"/>
</td>
</tr>
</table>port.aspx
有个textbox1 我现在如何把textbox1的值赋给控件CityPort1里面的tbport
有个控件
<uc1:CityPort ID="CityPort1" runat="server" />控件代码
CityPort.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CityPort.ascx.cs" Inherits="CityPort" %>
<table width="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width:130px">
<asp:TextBox ID="tbPort" runat="server" Width="130px"></asp:TextBox>
</td>
<td style="width:20px" valign="bottom">
<img src="images/button_search.gif" 20px" width="18px" id="IMG1" language="javascript" onclick="javascript:window.showModalDialog('port.aspx',window,'status:Modeless;edge:sunken;unadorned:no;scroll=no;resizable:no;dialogLeft:300;dialogtop:200;help:no;dialogwidth:400px;dialogheight:240px');void(0);"/>
</td>
</tr>
</table>port.aspx
有个textbox1 我现在如何把textbox1的值赋给控件CityPort1里面的tbport
{
get
{
return tbPort.Text;
}
set
{
tbPort.Text = value;
}
}然后这样赋值CityPort1.Port = textbox1.Text;2.方法二(不推荐),(CityPort1.FindControl("tbPort") as TextBox).Text = textbox1.Text;
CityPort.ascx里的tbPort...
我用this.btnApply.Attributes.Add("onclick", "window.dialogArguments.document.all.CityPort1.Port='www.sohu.com';window.close();");不可以.对了如果是控件的话那么这个<uc1:CityPort 的id是变化的.那么就不能通用.
能帮我解决下先谢谢了。.......
public TextBox PortTextControl
{
get
{
return tbPort;
}
}然后:
this.btnApply.Attributes.Add("onclick", string.Format( "window.dialogArguments.document.all.{0}='www.sohu.com';window.close();" CityPort.PortTextControl.ClientID ));