placeholder
-
As i dim a new checkbox together with other information and place into a placeholder. If i DIM 3, mine placeholder will carry 3 checkboxes and its information. So,if i want to get the id upon selection (eg.checkbox1.checked=true). In this case where i have a placeholder of checkbox. So i can i check for the selected box? How can i traverse the placeholder? For ph=0 to phDiv.controls.count-1? my code is liek this: For ph = 0 To phDiv.Controls.Count - 1 Dim cb As CheckBox = phDiv.Controls.Item(ph).FindControl("cbx") If cb.Checked = True Then Dim id As String = cb.ID ..... next This cant work.
-
As i dim a new checkbox together with other information and place into a placeholder. If i DIM 3, mine placeholder will carry 3 checkboxes and its information. So,if i want to get the id upon selection (eg.checkbox1.checked=true). In this case where i have a placeholder of checkbox. So i can i check for the selected box? How can i traverse the placeholder? For ph=0 to phDiv.controls.count-1? my code is liek this: For ph = 0 To phDiv.Controls.Count - 1 Dim cb As CheckBox = phDiv.Controls.Item(ph).FindControl("cbx") If cb.Checked = True Then Dim id As String = cb.ID ..... next This cant work.
From the few messages you had posted, I guess you have problems with 'checkbox'. It would be better if refer any documentation or any (good) book for ASP.NET and learn them and then come to CP if you are still having problems.... He who controls others may be powerful,
But he who has mastered himself is mightier still. -
From the few messages you had posted, I guess you have problems with 'checkbox'. It would be better if refer any documentation or any (good) book for ASP.NET and learn them and then come to CP if you are still having problems.... He who controls others may be powerful,
But he who has mastered himself is mightier still. -
Yes, i have problems with 'checkbox' BUT now the problem i have is the PALCEHOlDER. not 'checkbox'. Well, all i want to know weather is it possible to traverse the placeholder which contain control(eg checkbox).
Use the
FindControl
method of thePlaceHolder
. If you're not sure about the implementation, look it up in the MSDN library, it provides a good example. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii. -
Use the
FindControl
method of thePlaceHolder
. If you're not sure about the implementation, look it up in the MSDN library, it provides a good example. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.I did it this way cbx = New CheckBox cbx.ID = resourceid cbx.Text = txt cbx.ToolTip = desc phDiv.Controls.Add(cbx) So everything is under the properties of checkbox. So there is no need and cannot have the fincontrol method. I have tried that but it doesnt goes it the loop.Probably because there is only a checkbox and nothing else inside. Therefore i tried the method above. The coding is done is a method. However when i want to checked if the checkbox in placeholder is selected anot (in another method) It cannot access. For i=0 to ph.controls.count-1 It can capture the number of controls. Is this due to the coding in different method? But it should be okie i guess. Cause the placeholder is a existing control in the web form. What went wrong?
-
Use the
FindControl
method of thePlaceHolder
. If you're not sure about the implementation, look it up in the MSDN library, it provides a good example. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.I did it this way cbx = New CheckBox cbx.ID = resourceid cbx.Text = txt cbx.ToolTip = desc phDiv.Controls.Add(cbx) So everything is under the properties of checkbox. So there is no need and cannot have the fincontrol method. I have tried that but it doesnt goes it the loop.Probably because there is only a checkbox and nothing else inside. Therefore i tried the method above. The coding is done is a method. However when i want to checked if the checkbox in placeholder is selected anot (in another method) It cannot access. For i=0 to ph.controls.count-1 It can capture the number of controls. Is this due to the coding in different method? But it should be okie i guess. Cause the placeholder is a existing control in the web form. What went wrong?
-
I did it this way cbx = New CheckBox cbx.ID = resourceid cbx.Text = txt cbx.ToolTip = desc phDiv.Controls.Add(cbx) So everything is under the properties of checkbox. So there is no need and cannot have the fincontrol method. I have tried that but it doesnt goes it the loop.Probably because there is only a checkbox and nothing else inside. Therefore i tried the method above. The coding is done is a method. However when i want to checked if the checkbox in placeholder is selected anot (in another method) It cannot access. For i=0 to ph.controls.count-1 It can capture the number of controls. Is this due to the coding in different method? But it should be okie i guess. Cause the placeholder is a existing control in the web form. What went wrong?
Try this, or something like it:
Private Sub Page\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack And CType(Session("CheckBox"), Boolean) Then CreateDynamicCheckbox() End If End Sub Private Sub CreateCheckBox\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateCheckBox.Click CreateDynamicCheckbox() End Sub Private Sub CreateDynamicCheckbox() Dim cb As New CheckBox cb.ID = "MyCheckBox" cb.Text = "Check Me" cb.Checked = True PlaceHolder1.Controls.Add(cb) Session("CheckBox") = True End Sub Private Sub RevealCheckBoxValue\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RevealCheckBoxValue.Click Dim cb As CheckBox = CType(PlaceHolder1.FindControl("MyCheckBox"), CheckBox) Label1.Text = "MyCheckBox value is " + cb.Checked.ToString() End Sub
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
Try this, or something like it:
Private Sub Page\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack And CType(Session("CheckBox"), Boolean) Then CreateDynamicCheckbox() End If End Sub Private Sub CreateCheckBox\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateCheckBox.Click CreateDynamicCheckbox() End Sub Private Sub CreateDynamicCheckbox() Dim cb As New CheckBox cb.ID = "MyCheckBox" cb.Text = "Check Me" cb.Checked = True PlaceHolder1.Controls.Add(cb) Session("CheckBox") = True End Sub Private Sub RevealCheckBoxValue\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RevealCheckBoxValue.Click Dim cb As CheckBox = CType(PlaceHolder1.FindControl("MyCheckBox"), CheckBox) Label1.Text = "MyCheckBox value is " + cb.Checked.ToString() End Sub
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
I have 3 checkboxes in my placeholder and i did as follows: **Private Sub Page_Load(**ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack And CType(Session("Checkbox"), Boolean) Then createcheckbox() End If Private sub createcheckbox() txt = ownCname & " / " & ownDiv & " - " & resourcename & " ( " & capacity & " ) " cbx = New CheckBox cbx.ID = "MYCHECKBOX" cbx.Text = txt cbx.ToolTip = desc phDiv.Controls.Add(cbx) Session("Checkbox") = True ens sub private sub createcalendar() Dim cb As CheckBox = CType(phDiv.FindControl("MYCHECKBOX"), CheckBox) If cb.Checked = True Then rname = cb.Text : : End Sub Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnGo.Click createCalendar() End sub Am i wrong to do it this way? However, this works perfectly for the first checkbox in the placeholder if it's checked. If the second checkbox is selected, this code cant works. anythng wrong with my codes?Or i should set the cb.checked to true for all?
-
I have 3 checkboxes in my placeholder and i did as follows: **Private Sub Page_Load(**ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IsPostBack And CType(Session("Checkbox"), Boolean) Then createcheckbox() End If Private sub createcheckbox() txt = ownCname & " / " & ownDiv & " - " & resourcename & " ( " & capacity & " ) " cbx = New CheckBox cbx.ID = "MYCHECKBOX" cbx.Text = txt cbx.ToolTip = desc phDiv.Controls.Add(cbx) Session("Checkbox") = True ens sub private sub createcalendar() Dim cb As CheckBox = CType(phDiv.FindControl("MYCHECKBOX"), CheckBox) If cb.Checked = True Then rname = cb.Text : : End Sub Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnGo.Click createCalendar() End sub Am i wrong to do it this way? However, this works perfectly for the first checkbox in the placeholder if it's checked. If the second checkbox is selected, this code cant works. anythng wrong with my codes?Or i should set the cb.checked to true for all?
Ahhhh... second checkbox! You need essentially the same kind of code for each object; you could re-write the same code over and over, or do something generic (like a sub that generates a checkbox that takes as its parameters a container and an ID)... but whatever you do, ensure that each checkbox is different -- a different id, at least, by which you can identify it. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
Ahhhh... second checkbox! You need essentially the same kind of code for each object; you could re-write the same code over and over, or do something generic (like a sub that generates a checkbox that takes as its parameters a container and an ID)... but whatever you do, ensure that each checkbox is different -- a different id, at least, by which you can identify it. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
The checkboxes are kind of functioning now. But i think due to the pageload codes, there are some confusion or whatsoever because when i first view the page, everything works perfectly. However, when page ispostback, upon the first button click, no event was called. Only when i clicked the 2nd time the table is then generated. Why is this so? Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If IsPostBack And CType(Session("Checkbox"), Boolean) Then createcheckbox() End If If Not Session("ButtonCreated") Is Nothing Then buttoncreated = CType(Session("ButtonCreated"), Boolean) Else buttoncreated = False End If If IsPostBack And buttoncreated Then createCalendar() End If End sub Is it due to the 2 different tracking(one for the checkbox and one for the imagebutton)? Only either one can work at a time, not concurrently. Now that mine checkbox can work, my imagebutton cant(which workly perfectly the other day).
-
Ahhhh... second checkbox! You need essentially the same kind of code for each object; you could re-write the same code over and over, or do something generic (like a sub that generates a checkbox that takes as its parameters a container and an ID)... but whatever you do, ensure that each checkbox is different -- a different id, at least, by which you can identify it. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-Now the checkboxes work but the imagebutton click cannot(which work perfectly the previous time). Is this due the the page load code where both ispostback are place together? Both can work if only they are on different forms and only one can function in the particualar form. -one more problem:(checkbox) when i first view a particular page, everything was displayed as expected. however, when i make another selection (which is page ispostback), I'm able to view the data on the second button click. Which means when i first select and click on the button, no event was called but the breaskpoint did step into the method. Only upon 2nd selection and buttonClick, the data was then displayed. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If IsPostBack And CType(Session("Checkbox"), Boolean) Then-->checkbox createcheckbox() End If If Not Session("ButtonCreated") Is Nothing Then---> imagebutton buttoncreated = CType(Session("ButtonCreated"), Boolean) Else buttoncreated = False End If If IsPostBack And buttoncreated Then createCalendar() End If End sub Is this due to the code in the page load? These are the codes you gave me and i have edited some and implement it
-
-Now the checkboxes work but the imagebutton click cannot(which work perfectly the previous time). Is this due the the page load code where both ispostback are place together? Both can work if only they are on different forms and only one can function in the particualar form. -one more problem:(checkbox) when i first view a particular page, everything was displayed as expected. however, when i make another selection (which is page ispostback), I'm able to view the data on the second button click. Which means when i first select and click on the button, no event was called but the breaskpoint did step into the method. Only upon 2nd selection and buttonClick, the data was then displayed. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If IsPostBack And CType(Session("Checkbox"), Boolean) Then-->checkbox createcheckbox() End If If Not Session("ButtonCreated") Is Nothing Then---> imagebutton buttoncreated = CType(Session("ButtonCreated"), Boolean) Else buttoncreated = False End If If IsPostBack And buttoncreated Then createCalendar() End If End sub Is this due to the code in the page load? These are the codes you gave me and i have edited some and implement it
Right... well... hmmm... The code I gave you was fairly generalized and not particularly optimized to a particular implementation. Therefore, it is difficult to characterize what you've shown here as "right" or "wrong". If anything, I'd refactor and simplify as much as possible:
Protected checkboxExists As Boolean
Protected buttonExists As BooleanPrivate Sub Page_Load(...) ...
If IsPostBack Then
Dim checkboxExists As Boolean = CType(Session("Checkbox"), Boolean)
Dim buttonExists As Boolean = CType(Session("ButtonCreated"), Boolean)
If checkboxExists Then
createCheckBox()
End If
If buttonExists Then
createCalendar()
End If
End If
Session("CheckBox") = checkboxExists
Session("ButtonCreated") = buttonExists
End SubThis is normally the point at which it becomes increasingly difficult to impart any significant advice, unless there is something specific that is terribly wrong; at this point, you have to {code, test, debug} as many times as it takes to get it right. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
Right... well... hmmm... The code I gave you was fairly generalized and not particularly optimized to a particular implementation. Therefore, it is difficult to characterize what you've shown here as "right" or "wrong". If anything, I'd refactor and simplify as much as possible:
Protected checkboxExists As Boolean
Protected buttonExists As BooleanPrivate Sub Page_Load(...) ...
If IsPostBack Then
Dim checkboxExists As Boolean = CType(Session("Checkbox"), Boolean)
Dim buttonExists As Boolean = CType(Session("ButtonCreated"), Boolean)
If checkboxExists Then
createCheckBox()
End If
If buttonExists Then
createCalendar()
End If
End If
Session("CheckBox") = checkboxExists
Session("ButtonCreated") = buttonExists
End SubThis is normally the point at which it becomes increasingly difficult to impart any significant advice, unless there is something specific that is terribly wrong; at this point, you have to {code, test, debug} as many times as it takes to get it right. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
Well, this problem has been solved. However, the imagebutton still can't work!! It works before i add the mouseover tooltip. Stil wondering what went wrong. Can help? The codes in page_load is the same as above(what you gave) Createcalendar subroutin when i create the imagebutton: Dim img As New ImageButton AddHandler img.Click, AddressOf ImageClickHandler img.ImageUrl = Server.MapPath("Pics\pencil.gif") cellleft.Controls.Add(img) row.Controls.Add(cellleft) buttoncreated = True Session("ButtonCreated") = buttoncreated what went wrong? :sigh:
-
Right... well... hmmm... The code I gave you was fairly generalized and not particularly optimized to a particular implementation. Therefore, it is difficult to characterize what you've shown here as "right" or "wrong". If anything, I'd refactor and simplify as much as possible:
Protected checkboxExists As Boolean
Protected buttonExists As BooleanPrivate Sub Page_Load(...) ...
If IsPostBack Then
Dim checkboxExists As Boolean = CType(Session("Checkbox"), Boolean)
Dim buttonExists As Boolean = CType(Session("ButtonCreated"), Boolean)
If checkboxExists Then
createCheckBox()
End If
If buttonExists Then
createCalendar()
End If
End If
Session("CheckBox") = checkboxExists
Session("ButtonCreated") = buttonExists
End SubThis is normally the point at which it becomes increasingly difficult to impart any significant advice, unless there is something specific that is terribly wrong; at this point, you have to {code, test, debug} as many times as it takes to get it right. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
How many ImageButton controls are you creating and how many times is the method called? What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
How many ImageButton controls are you creating and how many times is the method called? What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
One imagebutton is created when the date is >=date.today and also depends on the number of records in the database. So it hard for me to estimate the number imagebutton controls i wil be creating. It will check against the date and number of records in database. How many time the method is called depends on the number of rows.
-
How many ImageButton controls are you creating and how many times is the method called? What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
How many ImageButton controls are you creating and how many times is the method called? What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
help help PLEASE...........................................................................urgent
Sorry about the delay -- Holiday weekend and all. I tried to get this to work, but I couldn't, either. :( Have you considered abandoning the default Calendar control and creating your own class? What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
Sorry about the delay -- Holiday weekend and all. I tried to get this to work, but I couldn't, either. :( Have you considered abandoning the default Calendar control and creating your own class? What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.