Click here to Skip to main content
16,017,015 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: PDF to Images for encryption Pin
F-ES Sitecore6-Oct-20 6:08
professionalF-ES Sitecore6-Oct-20 6:08 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 6:52
Member 105489776-Oct-20 6:52 
GeneralRe: PDF to Images for encryption Pin
F-ES Sitecore6-Oct-20 10:45
professionalF-ES Sitecore6-Oct-20 10:45 
GeneralRe: PDF to Images for encryption Pin
Member 105489777-Oct-20 7:00
Member 105489777-Oct-20 7:00 
GeneralRe: PDF to Images for encryption Pin
Member 105489776-Oct-20 3:22
Member 105489776-Oct-20 3:22 
QuestionDynamically added controls effecting other controls Pin
Member 149556174-Oct-20 11:22
Member 149556174-Oct-20 11:22 
AnswerRe: Dynamically added controls effecting other controls Pin
Richard Deeming5-Oct-20 2:55
mveRichard Deeming5-Oct-20 2:55 
GeneralRe: Dynamically added controls effecting other controls Pin
Member 149416716-Oct-20 1:16
Member 149416716-Oct-20 1:16 
Because I don't think its connected to my code, its something about dynamic controls or viewstate that I don't understand, and therefore can't answer myself..(I think)

but anyway... here is the code of the page
ASP.NET
<pre> <%-- this div contains user professions --%>
    <div id ="registrationP3" runat="server" visible="false">
        <div id="CheckboxProf" class="radios" runat="server" visible="false" Enableviewstate="false">
        </div>
    </div>
     <%-- this div contains username skills at programs/programming --%>
    <div id ="registrationP4" runat="server" visible="false">
        <div id="CheckboxProg" class="radios" runat="server" visible="false" EnableViewState="false">
        </div>
        <asp:Button ID="register" runat="server" Text="Register" OnClick="register_Click"  />
    </div>
    <asp:Button ID="next" runat="server" Text="next" OnClick="next_Click"  />



here is the code that creates the checkboxes:
C#
<pre>public static void BindProfessions(HtmlControl ctrl, Page thispage)
        {
            List<Profession> Plist = Profession.GetProfessionList();
            foreach (Profession p in Plist)
            {
                HtmlInputCheckBox rd_button = new HtmlInputCheckBox();
                const string GROUP_NAME = "Professions";
                rd_button.Name = GROUP_NAME;
                string LinkID = "P" + p.ProfessionID.ToString();
                rd_button.Attributes["id"] = LinkID;
                rd_button.Value = p.ProfessionID.ToString();
                RegisterUserControl userprofession = (RegisterUserControl)thispage.LoadControl("~/RegisterUserControl.ascx");
                userprofession.imgP = p.ProfPath;
                userprofession.fieldName = p.ProfName;
                userprofession.IDnum = p.ProfessionID;
                userprofession.RadioName = LinkID;
                userprofession.EnableViewState = false;
                rd_button.EnableViewState = false;
                ctrl.Controls.Add(rd_button);
                ctrl.Controls.Add(userprofession);
            }
        }


        public static void BindKnowledge(HtmlControl ctrl, Page thispage)
        {
            List<Knowledge> Plist = Knowledge.RetKnowledgeList();
            foreach (Knowledge p in Plist)
            {
                HtmlInputCheckBox checkBox = new HtmlInputCheckBox();
                const string GROUP_NAME = "knowledge";
                checkBox.Name = GROUP_NAME;
                string LinkID = "Know" + p.ProgramID.ToString();
                checkBox.Attributes["id"] = LinkID;
                checkBox.Value = p.ProgramID.ToString();
                RegisterUserControl userprofession = (RegisterUserControl)thispage.LoadControl("~/RegisterUserControl.ascx");
                userprofession.imgP = p.ProgPath;
                userprofession.fieldName = p.PName;
                userprofession.IDnum = p.ProgramID;
                userprofession.RadioName = LinkID;
                userprofession.EnableViewState = false;
                checkBox.EnableViewState = false;
                ctrl.Controls.Add(checkBox);
                ctrl.Controls.Add(userprofession);
            }
        }


here is the code that checkes the checkboxes after the user clicks submit
C#
<pre> /// <summary>
        /// go over the ctrl and gets the checkbox's which theirs ""
        /// </summary>
        public static List<int> GetCheckBox(HtmlControl ctrl)
        {
            List<int> id_list = new List<int>();
            //ControlCollection li = ctrl.Controls;
            //List < Control > li2 = new List<Control>();
            //foreach(Control liitem in li)
            //{
            //    li2.Add(liitem);
            //}
            foreach (Control rdButton in ctrl.Controls)
            {
                if (rdButton is HtmlInputCheckBox)
                {
                    HtmlInputCheckBox bu = (HtmlInputCheckBox)rdButton;
                    if (bu.Checked)
                    {
                        id_list.Add(int.Parse(bu.Value));
                    }
                }
            }
            return id_list;
        }




here is the Page_Load in which I create the checkboxes once again with BindProfession, pay attention to the third if

C#
protected void Page_Load(object sender, EventArgs e)
       {
           IsPageRefresh = false;
           if (!IsPostBack)
           {
               ViewState["DivID"] = 1;
               ViewState["postids"] = System.Guid.NewGuid().ToString();
               Session["postid"] = ViewState["postids"].ToString();
           }
           else
           {
               if (ViewState["postids"].ToString() != Session["postid"].ToString())
               {
                   IsPageRefresh = true;
               }
               Session["postid"] = System.Guid.NewGuid().ToString();
               ViewState["postids"] = Session["postid"].ToString();
           }
           if (int.Parse(ViewState["DivID"].ToString()) == 3)
           {
               BindProfessions(CheckboxProf, Page); // problematic bind, if I choose not do build the checkboxes again, the problem does not happen (if I remove this line of code)
           }
           else if(int.Parse(ViewState["DivID"].ToString()) == 4)
           {
               BindKnowledge(CheckboxProg, Page);
           }

       }

Questiontrying to get some measurement data to ASP from Microsoft SQL? Pin
auting824-Oct-20 11:07
auting824-Oct-20 11:07 
AnswerRe: trying to get some measurement data to ASP from Microsoft SQL? Pin
Richard Deeming5-Oct-20 2:53
mveRichard Deeming5-Oct-20 2:53 
QuestionComplex View Model with Nested Item List / ModelState Pin
Guillermo Perez18-Sep-20 15:49
Guillermo Perez18-Sep-20 15:49 
AnswerRe: Complex View Model with Nested Item List / ModelState Pin
Richard Deeming27-Sep-20 22:21
mveRichard Deeming27-Sep-20 22:21 
QuestionFireFox Upload Images Pin
Member 105489774-Sep-20 6:23
Member 105489774-Sep-20 6:23 
AnswerRe: FireFox Upload Images Pin
Richard Deeming6-Sep-20 23:09
mveRichard Deeming6-Sep-20 23:09 
GeneralRe: FireFox Upload Images Pin
Member 1054897717-Sep-20 5:31
Member 1054897717-Sep-20 5:31 
GeneralRe: FireFox Upload Images Pin
Richard Deeming17-Sep-20 9:06
mveRichard Deeming17-Sep-20 9:06 
GeneralRe: FireFox Upload Images Pin
Member 1054897718-Sep-20 5:48
Member 1054897718-Sep-20 5:48 
GeneralRe: FireFox Upload Images Pin
Richard Deeming20-Sep-20 23:40
mveRichard Deeming20-Sep-20 23:40 
GeneralRe: FireFox Upload Images Pin
Member 1054897717-Sep-20 5:36
Member 1054897717-Sep-20 5:36 
GeneralRe: FireFox Upload Images Pin
Member 1054897718-Sep-20 5:29
Member 1054897718-Sep-20 5:29 
QuestionShow DataTable in Json Pin
Member 149089644-Sep-20 0:20
Member 149089644-Sep-20 0:20 
AnswerRe: Show DataTable in Json Pin
F-ES Sitecore4-Sep-20 2:43
professionalF-ES Sitecore4-Sep-20 2:43 
GeneralRe: Show DataTable in Json Pin
Member 1490896421-Sep-20 1:48
Member 1490896421-Sep-20 1:48 
GeneralRe: Show DataTable in Json Pin
F-ES Sitecore21-Sep-20 1:51
professionalF-ES Sitecore21-Sep-20 1:51 
GeneralRe: Show DataTable in Json Pin
Member 1490896421-Sep-20 3:47
Member 1490896421-Sep-20 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.