问题描述
我的代码如下namespaceGethome.Web.user{publicpartialclassInviteUser:Gethome.Web.UI.Page.BasePage{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){if(Request.Form["Register"]=="Submit"){DoRegister(UbInfo);}}}这个方法是获取选择的ID的protectedvoidDoRegister(){intId=Convert.ToInt32(Dro_Appellation.SelectedValue)}protectedvoidDro_beifen_SelectedIndexChanged(objectsender,EventArgse){stringSex=Dro_Sex.SelectedValue;stringSeniority=Dro_beifen.SelectedValue;IhomeAppellationInfoIh=newIhomeAppellationInfo();Ih.Sex=Sex;Ih.Seniority=Seniority;Dro_Appellation.DataSource=newIhomeAppellation().SelectIhome(Ih);Dro_Appellation.DataTextField="Appellation";Dro_Appellation.DataValueField="Id";Dro_Appellation.DataBind();}}}页面的效果是还有用户名呀密码什么的,太多了。我就省略了这里只是DropDownList<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate>性别:<asp:DropDownListID="Dro_Sex"runat="server"Height="16px"Width="36px"><asp:ListItemValue="0">男</asp:ListItem><asp:ListItemValue="1">女</asp:ListItem></asp:DropDownList>辈分:<asp:DropDownListID="Dro_beifen"runat="server"AutoPostBack="True"Height="16px"onselectedindexchanged="Dro_beifen_SelectedIndexChanged"><asp:ListItemValue="1">长辈</asp:ListItem><asp:ListItemValue="0">同辈</asp:ListItem><asp:ListItemValue="-1">晚辈</asp:ListItem></asp:DropDownList>请选择<asp:DropDownListID="Dro_Appellation"runat="server"></asp:DropDownList></ContentTemplate></asp:UpdatePanel>我的效果是,在我选择男女后再选择辈分。辈分那里回传的,当我选择辈分后就会自动跳的后台那里给请选择那个下拉框赋值,我现在遇到的问题是选择辈分选好后,请选择那里也出来了,选好后,当我点击提交后。if(!IsPostBack)这里的不运行了。因为我的添加方法就在这里面写着,并且,我实验着把我的那个添加方法写在外面后,请选择那里的DropDownList我在后台取得值一直都是第一个选项的值我实在是搞不懂了。晕了
解决方案
解决方案二:
DoRegister(UbInfo);这里不用传参的,。这个写错了
解决方案三:
if(!IsPostBack)这里的不运行了。因为我的添加方法就在这里面写着,添加方法怎么能写在这里呢?按钮的事件处理方法都是这样的方法:Button1_Click(objectsender,EventArgse){}if(!IsPostBack)是写在Page_Load里面的
解决方案四:
DoRegister(UbInfo);=>protectedvoidDoRegister()参数值?<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><div><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:DropDownListID="ddlLB"runat="server"Width="15%"AutoPostBack="True"OnSelectedIndexChanged="ddlLB_SelectedIndexChanged"></asp:DropDownList><asp:DropDownListID="ddlChild"runat="server"Width="20%"></asp:DropDownList></ContentTemplate></asp:UpdatePanel></div>
解决方案五:
求高手
解决方案六:
protectedvoidDro_beifen_SelectedIndexChanged(objectsender,EventArgse){if(!IsPostBack){//把他的回传方法用一个postback框起来试一下,我没试,不知道行不行stringSex=Dro_Sex.SelectedValue;stringSeniority=Dro_beifen.SelectedValue;IhomeAppellationInfoIh=newIhomeAppellationInfo();Ih.Sex=Sex;Ih.Seniority=Seniority;Dro_Appellation.DataSource=newIhomeAppellation().SelectIhome(Ih);Dro_Appellation.DataTextField="Appellation";Dro_Appellation.DataValueField="Id";Dro_Appellation.DataBind();}}
解决方案七:
引用5楼yesterday5100的回复:
C#codeprotectedvoidDro_beifen_SelectedIndexChanged(objectsender,EventArgse){if(!IsPostBack){//把他的回传方法用一个postback框起来试一下,我没试,不知道行不行stringSex=Dro_Sex.SelectedValue;stringSen……
不行哦、。这样写的话,。根本就不进去
解决方案八:
引用楼主xcy_wwj的回复:
我的代码如下namespaceGethome.Web.user{publicpartialclassInviteUser:Gethome.Web.UI.Page.BasePage{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){……
我现在修改了一下。我把按钮给去了。加了一个控件按钮,我的我点击按钮时,他居然不跳的按钮的事件里面。反而就跳到那个下拉菜单那里绑定去了。最后得到的还是第一个值,。我超级郁闷呀后台代码[code=C#]namespaceGethome.Web.user{publicpartialclassInviteUser:Gethome.Web.UI.Page.BasePage{protectedstringprovince=string.Empty;protectedstringcityarray=string.Empty;protectedboolsucceed=false;protectedstringerror=string.Empty;protectedstringemail=string.Empty;protectedvoidPage_Load(objectsender,EventArgse){intID=this.GetUserID();UserBasicInfoUbInfo=newGethome.BLL.User.User().GetUserBasic(ID);if(UbInfo.Colonel==1){if(UiConfig.RegSwitch=="0"){PageError("现在还未开放邀请功能","/user/default.aspx");}if(!IsPostBack){if(!succeed){Dictdict=newDict();IList<DictAreaInfo>list=dict.GetArea();foreach(DictAreaInfoinfoinlist){if(info.ParentID.Equals(0)){province+="<optionvalue=""+info.ID+"">"+info.Name+"</option>";}else{if(!cityarray.Equals(string.Empty))cityarray+=",";cityarray+="newArray('"+info.ParentID+"','"+info.ID+"','"+info.Name+"')";}}DataBind();}}}else{Response.Write("<script>alert('你不是族长不能邀请人!!');self.document.location.href='default.aspx'</script>");}}protectedvoidbtnok_Click(objectsender,EventArgse){intID=this.GetUserID();UserBasicInfoUbInfo=newGethome.BLL.User.User().GetUserBasic(ID);DoRegister(UbInfo);}///<summary>///注册///</summary>protectedvoidDoRegister(UserBasicInfoUbInfo){UserInfoui=newUserInfo();ui.Email=email=Request["TxtEmail"];//获取用户的名字stringUserName=Request["TxtName"];ui.Username=UserName;//默认密码为1111ui.Password="1111";ui.Province=Convert.ToInt32(Request["SlctProvince"]);ui.City=Convert.ToInt32(Request["SlctCity"]);Gethome.BLL.User.UserUser=newUser();EnumRegisterret=User.Register(ui);intUserId=User.GetMaxUserID();if(ret==EnumRegister.Succeed){//默认添加一个圈UserBasicInfoub=newUserBasicInfo();ub.UserID=UserId;ub.Sex=2;ub.RealName=UserName;ub.Colonel=0;ub.Group.GroupID=UbInfo.Group.GroupID;ub.Appell.Id=Convert.ToInt32(Dro_Appellation.SelectedValue.ToString());intnum=newGethome.BLL.User.User().AddUserBase(ub);if(num>0){GroupMember(UserId,UbInfo.Group.GroupID);succeed=true;}}elseif(ret==EnumRegister.EmailRepeat){error="该Email地址已注册过帐户";}elseif(ret==EnumRegister.EmailMayNotSend){#regionCMS整合stringuname=ui.Email.Split('@')[0];Gethome.API.Interface.PDOActionpdo=newGethome.API.Interface.PDOAction();if(pdo.Enabled()){pdo.RegUser(uname,ui.Password,100,100,"0",ui.Email,"","111111","111111",ui.Username,"","","",Public.GetClientIP(),1,true,"");pdo.Login(ui.Email,ui.Password,1);}#endregionerror="你已经成功注册,请你稍后检查邮箱,如果没有收到帐号确认邮件,请与客服联系";}else{error="系统错误,请稍后再试";}}protectedvoidGroupMember(intUserID,intGroupID){GroupMemberInfogm=newGroupMemberInfo();gm.Group.GroupID=GroupID;gm.UserBasic.UserID=UserID;gm.JoinTime=DateTime.Now;gm.Grade=EnumGroupGrade.Common;intnum=newGethome.BLL.User.GroupMember().Join(gm);if(num>0){Response.Write("<script>alert('邀请成功!!');self.document.location.href='default.aspx'</script>");}else{newGethome.BLL.User.User().DelUser(UserID,0);newGethome.BLL.User.User().DelectUserBase(UserID);}}protectedvoidDro_beifen_SelectedIndexChanged(objectsender,EventArgse){stringSex=Dro_Sex.SelectedValue;stringSeniority=Dro_beifen.SelectedValue;IhomeAppellationInfoIh=newIhomeAppellationInfo();Ih.Sex=Sex;Ih.Seniority=Seniority;Dro_Appellation.DataSource=newIhomeAppellation().SelectIhome(Ih);Dro_Appellation.DataTextField="Appellation";Dro_Appellation.DataValueField="Id";Dro_Appellation.DataBind();}}}
解决方案九:
直接写在服务器控件事件Button_Click事件里面应该可以吧!
解决方案十:
页面代码<body><divid="headarea"><!--#includefile="../head0.htm"--></div><divid="mainarea"><divid="mleft"><!--#includefile="../left0.htm"--></div><divid="mright"><divid="mid"><divclass="container"><divid="content"><divclass="mainnoright"><%if(error!=string.Empty){%><divclass="msg-error"><%#error%></div><%}if(!succeed){%><divclass="block"><h3>邀请亲人</h3><formid="formreg"runat="server"><p><labelclass="f-label"for="email_reg">Email</label><inputtype="text"id="TxtEmail"name="TxtEmail"onblur="returncheckemail();"class="f-text"value=""/><spanclass="error"id="err_mail"style="display:none;">请输入有效的Email</span><spanclass="hint"id="hnt_mail">用来登录<%#Gethome.Config.UiConfig.SiteName%>,不会对外公开</span></p><p><labelclass="f-label"for="realname">姓名</label><inputtype="text"runat="server"id="TxtName"name="TxtName"onblur="checkname();"class="f-text"value=""maxlength="12"onclick="returnTxtName_onclick()"/><spanclass="hint"id="hnt_name">请输入真实姓名</span></p><p><labelclass="f-label"for="province">邀请人所在地</label><selectname="SlctProvince"id="SlctProvince"onchange="ChangeProv(this);"><optionvalue="0"selected="selected"></option><%#province%></select><selectname="SlctCity"id="SlctCity"style="display:none;"></select><spanclass="error"id="err_addr"style="display:none;">请选择所在地</span></p><p><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate>性别:<asp:DropDownListID="Dro_Sex"runat="server"Height="16px"Width="36px"><asp:ListItemValue="0">男</asp:ListItem><asp:ListItemValue="1">女</asp:ListItem></asp:DropDownList>辈分<asp:DropDownListID="Dro_beifen"runat="server"AutoPostBack="True"Height="16px"onselectedindexchanged="Dro_beifen_SelectedIndexChanged"><asp:ListItemValue="1">长辈</asp:ListItem><asp:ListItemValue="0">同辈</asp:ListItem><asp:ListItemValue="-1">晚辈</asp:ListItem></asp:DropDownList>请选择<asp:DropDownListID="Dro_Appellation"runat="server"EnableViewState="False"></asp:DropDownList></ContentTemplate></asp:UpdatePanel></p><pclass="act"><asp:Buttonid="btnok"class="f-button"runat="server"Text="邀请"style="height:26px"onclick="btnok_Click"/></p><p><labelclass="f-check"for="agreement"><inputtype="checkbox"id="agreement"onclick="checkconfer(this);"onchange="checkconfer(this);"checked="checked"value="on"name="agreement"/>我已阅读并接受</label><ahref="../help/?a=protocol"target="_blank">《邀请协议》</a></p><inputtype="hidden"name="Register"id="city"value="Submit"/></form></div><%}else{%><divclass="block"><h3>验证你的Email地址</h3><p>你的邀请我们已发送了一封验证邮件到他(她)邮箱<strong><%#email%></strong>,查收该邮件完成邀请。</p><pstyle="font-size:14px;"><buttonclass="f-button"onclick="window.open('<%#Gethome.Config.EmailConfig.GetEmailLoginUrl(email)%>')">点击这里登录你的邮箱</button></p><divstyle="color:#800;">注意看看是否在垃圾箱里。<divstyle="margin-top:10px;color:Red;">如果确实没有收到验证邮件。请用你的注册邮箱给service@gethome.cn发一封标题为“验证”的邮件,管理员将协助你激活帐号。</div></div></div><%}%></div></div><br/><br/><br/></div><divclass="bottombg"></div><divid="bottomarea"><!--#includefile="footer.htm"--></div></div></div></div></body></html>
解决方案十一:
引用8楼softkexin的回复:
直接写在服务器控件事件Button_Click事件里面应该可以吧!
写进去了。,他跑得下拉菜单那里又重新绑定一下
解决方案十二:
引用10楼xcy_wwj的回复:
引用8楼softkexin的回复:直接写在服务器控件事件Button_Click事件里面应该可以吧!写进去了。,他跑得下拉菜单那里又重新绑定一下
你再看下我发的代码
解决方案十三:
引用3楼wuyq11的回复:
DoRegister(UbInfo);=>protectedvoidDoRegister()参数值?<asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><div><asp:UpdatePanelID="UpdatePanel1"runat="s……
哇塞第一次看见状元冒泡
解决方案十四:
DoRegister(UbInfo);这个方法调用的有问题