|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
HELP!! Dynamically created webcontrol not accessible on postbackcheckbox during the DayRender event as follows: System.Web.UI.WebControls.CheckBox cb = new System.Web.UI.WebControls.CheckBox(); cb = new System.Web.UI.WebControls.CheckBox(); cb.EnableViewState = true; cb.ID="p" + e.Day.Date.ToShortDateString().Replace("/","_"); cb.CheckedChanged += new System.EventHandler(this.CheckBox_CheckedChanged); cb.Text = "Play"; e.Cell.Controls.Add(cb); I have a command button for submitting the changes but cannot figure out how to access the dynamically created checkboxes. The WebCalendar does not expose the table object it creates so how would I be able to access the values of these checkboxes?? I've kind of reached my end here...any help would be most appreciated.. On Each and every post back you need to reload dynamic controls. The
viewstate is posted back to the server but the interpreter cant put it anywhere because the controls dont exist. In the Stateless environs those controls dont persist, you have to recreate them. The data in the controls does persist. its in the Viewstate. I am aware that that technique will get you the viewstate back but how does
that get the value entered by the user? ViewState is the state that was sent to the user not what is recieved. Does the framework also take the values of the post and load it into the dynamic controls? Show quoteHide quote "Josh" <s@a.com> wrote in message news:e2ckec5VFHA.2984@tk2msftngp13.phx.gbl... > On Each and every post back you need to reload dynamic controls. The > viewstate is posted back to the server but the interpreter cant put it > anywhere because the controls dont exist. > > In the Stateless environs those controls dont persist, you have to > recreate them. The data in the controls does persist. its in the > Viewstate. > Please let me know if you found the solution, I'm facing the same
problem... don't know how to retrieve checked value.
--
vuive4ly
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1610540.html
This works for me, I was able to store Date in my Array if the checkbox
is checked
'-------------------------------------- Dim Arr(31) as string Sub calendarCS_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles calendarCS.DayRender If e.Day.IsOtherMonth = False Then Dim MyCheckbox As New CheckBox Dim i As Integer = e.Day.DayNumberText Dim chkID As String = "D" & i MyCheckbox.ID = chkID If arr(i) = e.Day.DayNumberText Then MyCheckbox.Checked = True Else MyCheckbox.Checked = False End If MyCheckbox.EnableViewState = True e.Cell.Controls.Add(MyCheckbox) End If End Sub '----------------------------------- Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim c As Control Dim i As Integer = 31 For i = 1 To 31 Dim D As New CheckBox Dim strID As String = "D" & i Dim strIDFound As String = Request.Form(strID) If strIDFound = "on" Then arr(i) = i lblError.Text += arr(i) & " " End If Next End Sub '------------------------------------ Hope it works for you guys too -- vuive4ly ------------------------------------------------------------------------ Posted via http://www.mcse.ms ------------------------------------------------------------------------ View this thread: http://www.mcse.ms/message1610540.html > I am aware that that technique will get you the viewstate back but how When you dynamically recreate the controls and add them back into the server > does that get the value entered by the user? ViewState is the state > that was sent to the user not what is recieved. > > Does the framework also take the values of the post and load it into > the dynamic controls? control tree, they will load their viewstate and the post data the user had entered. So the answer to your question is "yes" :) -Brock DevelopMentor http://staff.develop.com/ballen
Why don't child control events trigger OnBubbleEvent?
About CreateChildControls() Looking for an Autocomplete DropDownList looking for tab control / tabstrip in VS 2005 beta2 Multiple Label tags with same ID Validation on dynamic fields Datagrid ... is this the control from hell? What is .Net equivilent of Fieldset/Legend Datalist layout Programmatically Rotate Datagrid Rows |
|||||||||||||||||||||||