如何在页面 控制 用户控件里面某个控件的属性??比如 一个用户控件 是 搜索框  这个搜索框里面有个 下拉框(里面是整个网站的6个子栏目,便于分类搜索).  如何在 6个子栏目的页面aspx 的pageload 时 修改 搜索框用户控件里面 下拉框 的 被选择项.....

解决方案 »

  1.   

    参考这个:
    foreach (RepeaterItem item in this.Discipline1.DisciplineGroup.Items)
    {
    CheckBoxList tempCheckBoxList = (CheckBoxList)item.FindControl("chbdesciption");
    foreach (ListItem checkitem in tempCheckBoxList.Items)
    {
    if (checkitem.Selected)
    tempArray.Add(checkitem.Value);
    }
    }
    if (tempArray.Count == 0)
    {
    this.valFailed.IsValid = false;
    this.valFailed.ErrorMessage = "Please select scientific interests";
    return;
    }
    tempSolver.Interesting = tempArray; try
    {
    if (FileUpload1.HasFile)
    {
    FileType = FileUpload1.PostedFile.ContentType;
    FileSize = (int)FileUpload1.PostedFile.ContentLength;
    UploadImages(FileUpload1, "SolverPhoto\\", 50, 50, out FilePath, out FileName, out fileid); tempSolver.FileInfo.Id = fileid;
    tempSolver.FileInfo.ContentType = FileType;
    tempSolver.FileInfo.DateCreated = DateTime.Now;
    tempSolver.FileInfo.Name = FileName;
    tempSolver.FileInfo.Path = FilePath;
    tempSolver.FileInfo.Size = (long)FileSize;
    }
    else
    {
    //tempSolver.FileInfo = new Inno.Framework.FileInfo();
    tempSolver.FileInfo = null;
    }
    tempSolver.Insert();                //email send
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("Dear {0}", this.txtusername.Text);
                    sb.Append("<br><br>");
                    sb.Append("Thank you for registering for InnoCentive.<br><br>");
                    sb.Append("For security purposes, we are emailing you your new password.<br><br>");
                    sb.AppendFormat("Your password is: {0}<br><br>", tempPassword);
                    sb.Append("Please login and change this password by visiting the \"My Profile\" section of the website.<br><br>");
                    sb.Append("Best,<br>InnoCentive<br><br>");
                    sb.Append("Please DO NOT reply to this email. This is a post only email.<br><br>");
                    sb.Append("[InnoCentive is a registered trade of InnoCentive, Inc. Other product or service names mentioned herein are the trades of their respective owners.]");
                    sb.Append("<br><br>");
                    sb.Append("InnoCentive, Inc. 35 New England Business Center, Andover, Massachusetts 01810-1071 USA");                WebUtil.SendEmail(this.txtEmail.Text, "[email protected]", "Thank you for your registering", sb.ToString());
    this.vlSuccess.IsValid = false;
                    Page.ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", "<script>window.open(\"RegisterSuccessfully.aspx\",\"\",\"width=500,height=200,left=250,top=250\");window.location.href='../SignIn/SignIn.aspx';</script>"); }
    catch (Exception ex)
    {
    this.valFailed.IsValid = false;
    this.valFailed.ErrorMessage = ex.Message +"If you forget your password, please <a href=\"EmailConfirmation.aspx\">click</a> here and we will resend the password to you.";
    }
    }其中Discipline1是usercontrol..
    DisciplineGroup是discipline1中的repeater control名称
    在discipline1中声明一个属性如下
    public Repeater DisciplineGroup
        {
            get { return this.repDiscipline;}
        }