如何使用rad的usercontrol值填充文本框 [英] how to fill textbox with the usercontrol value of rad
问题描述
我有这个任务要做。
我有一个用户控件,有组织和接触选择器rad控制。联系人选择器显示电子邮件(如果有)。选择联系人后,我需要在联系人控件的正常aspx文本框中显示电子邮件。我怎样才能做到这一点?请通过查看我的代码来帮助,因为我尝试这样做。
Hi ,
I have this task to do .
I have a user control that has organization and contact selector rad control . The contact selector has email shown if available. when the contact is selected, i need to show the email in the normal aspx textbox from the contact control. how can i do that? please help by looking at my code as i tried doing like this.
public event Action<string> OnContactChanged;
#region Page Events
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
//ContactSelectorV2.OnContactChanged += ContactChanged;
UserControls_ContactSelectorV2 contact = new UserControls_ContactSelectorV2();
contact.OnContactChanged += ContactChanged;
}
OnContactChanged
是我试图在这里调用的usercontrol中的事件在父页面中。
当我写这个方法时:
OnContactChanged
is the event in the usercontrol which i tried to invoke here in the parent page.
when i wrote this method:
public void ContactChanged()
{
}
和我的文本框是txtEmail,但这不被认可。
我的aspx代码对于文本框是这样的:
and my textbox was txtEmail but this was not recognized.
my aspx code is like this for textbox:
<asp:TextBox ID="txtEmail" runat="server">
我已经包含了像user这样的用户控件是:
I have included the usercontrol like this :
<uc5:ContactSelectorV2 ID="ContactSelectorV2" runat="server"/>
我已经在页面中注册了这样的
for which i have registered in the page like this
<%@ Register Src="~/UserControls/ContactSelectorV2.ascx" TagName="ContactSelectorV2" TagPrefix="uc5" %>
请帮助asap ...
Please help asap...
推荐答案
如果您将所有单选按钮放在一个组中或者您正在使用radioButton List,为什么不要你没有使用SelectedIndexChanged事件,并在事件括号内捕获所选索引的值并将其呈现在文本框上
if you''re putting all your radio buttons in a group or you''re using radioButton List, why don''t you use the SelectedIndexChanged event, and inside the event brackets catch the value of selected index and render it on the textbox
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = RadioButtonList1.SelectedItem.ToString();
}
这篇关于如何使用rad的usercontrol值填充文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!