简单问题:CreateUserWizard控件使用 自定义创建用户步骤,如何访问自己加进去的控件 我使用CreateUserWizard的自定义创建用户步骤,然后在安全答案下边加了一行,然后放进去一个label和一个DropDownList 。为什么我在CreateUserWizard的CreatedUser事件里无法访问到这个控件。。CreateUserWizard控件自身包含控件的都可以用CreateUserWizard.*的方式来访问。直接在事件里写控件名称同样找不到新加的控件。。哪位达人指教一下。。谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下代码初中Msdn:ms-help://MS.MSDNQTR.v90.chs/dv_vwdcon/html/7983d61e-d317-4181-8ab9-cab549adf9dc.htm<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { // Determine the checkbox values. CheckBox subscribeCheckBox = (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox"); CheckBox shareInfoCheckBox = (CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox"); TextBox userNameTextBox = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"); MembershipUser user = Membership.GetUser(userNameTextBox.Text); user.Comment = "Subscribe=" + subscribeCheckBox.Checked.ToString() + "&" + "ShareInfo=" + shareInfoCheckBox.Checked.ToString(); Membership.UpdateUser(user); // Show or hide the labels based on the checkbox values. Label subscribeLabel = (Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel"); Label shareInfoLabel = (Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel"); subscribeLabel.Visible = subscribeCheckBox.Checked; shareInfoLabel.Visible = shareInfoCheckBox.Checked; } private bool UserExists(string username) { if (Membership.GetUser(username) != null) { return true; } return false; } protected void CreateUserWizard1_NextButtonClick(object sender, WizardNavigationEventArgs e) { if (e.CurrentStepIndex == 0) { if (SearchAccount.Text.Trim() == "" || UserExists(SearchAccount.Text)) { SearchAccountMessage.Text = "That account already exists. Please select an different account name."; e.Cancel = true; } else { TextBox userName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"); userName.Text = SearchAccount.Text; SearchAccountMessage.Text = ""; e.Cancel = false; } } }</script> 呵呵,果然可以,问题解决!多谢liuyeede 的帮助! 找到标签里 src的值 基本只限定 下面的字串格式 怎么捕获"动态联接库DLL初始化例程失败"? update不成 有谁知道怎么用代码读取水晶报表中分组字段的当前值? 麻烦大家帮忙看看有错吗?我用vb.net转的c#的一个简单数据层 Label显示问题 子页面让父页面进行一服务器事件 关于gridview问题 关于分页存储过程?急 100分哦哦哦哦哦 <% @Import Namespace="Packaging" %>为什么出错! .net用文件替换原来文件代码 着急着急!!!! 求WEB页面里的TABS
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
// Determine the checkbox values.
CheckBox subscribeCheckBox =
(CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox");
CheckBox shareInfoCheckBox =
(CheckBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox");
TextBox userNameTextBox =
(TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName"); MembershipUser user = Membership.GetUser(userNameTextBox.Text);
user.Comment = "Subscribe=" + subscribeCheckBox.Checked.ToString() + "&" +
"ShareInfo=" + shareInfoCheckBox.Checked.ToString();
Membership.UpdateUser(user); // Show or hide the labels based on the checkbox values.
Label subscribeLabel =
(Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel");
Label shareInfoLabel =
(Label)CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel"); subscribeLabel.Visible = subscribeCheckBox.Checked;
shareInfoLabel.Visible = shareInfoCheckBox.Checked;
} private bool UserExists(string username)
{
if (Membership.GetUser(username) != null) { return true; } return false;
} protected void CreateUserWizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
if (e.CurrentStepIndex == 0)
{
if (SearchAccount.Text.Trim() == "" || UserExists(SearchAccount.Text))
{
SearchAccountMessage.Text = "That account already exists. Please select an different account name.";
e.Cancel = true;
}
else
{
TextBox userName =
(TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
userName.Text = SearchAccount.Text;
SearchAccountMessage.Text = "";
e.Cancel = false;
}
}
}
</script>