placeholder
-
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.
-
mmmm..............:(( Have you considered abandoning the default Calendar control and creating your own class?:confused: I really have no idea what to do now...:mad: :confused::~ :confused::~ :confused::~ :confused::~
Sorry, :(( My brain ceased to function on this one. 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, :(( My brain ceased to function on this one. 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, :(( My brain ceased to function on this one. 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, :(( My brain ceased to function on this one. 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.
-
There must be something that links them together right? If not how come with the same code and just he change of checkbox codes, everything can't work??? Im going crazy soon.. Have been trying several ways..
Well, yes... I'm not certain which snippet you're referring to, but in general, bear in mind that you're writing code that responds to particular events and each control event is independent of others on the same page, except for the page level events, that fire each time the page loads or posts. So, if, for example, I write an event handler for a button that creates a checkbox dynamically and stores some indication of that in Session, and later on I write an event handler that responds to the click event of another control that also dynamically creates something, I have to store some other indicator of that in Session as well, and so on, for each thing that I do. Do you see? If need be, I can point to the places in MSDN that describe the sequence of events and ASP session or state management. 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, yes... I'm not certain which snippet you're referring to, but in general, bear in mind that you're writing code that responds to particular events and each control event is independent of others on the same page, except for the page level events, that fire each time the page loads or posts. So, if, for example, I write an event handler for a button that creates a checkbox dynamically and stores some indication of that in Session, and later on I write an event handler that responds to the click event of another control that also dynamically creates something, I have to store some other indicator of that in Session as well, and so on, for each thing that I do. Do you see? If need be, I can point to the places in MSDN that describe the sequence of events and ASP session or state management. 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 I can leave out the dynamic checkboxes. Will be using checkboxlist instead (which can wotk with the dynamic imagebutton the previous time), so i guess this wouldn't be much of a problem as compare to the dynamic checkbox, am i right? However, I got to run the weekly form before i can click the button of the daily?
Page load 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 private sub createcalendar() imgholi.ID = rid imgholi.ImageUrl = Server.MapPath("Pics\pencil.gif") AddHandler imgholi.Click, AddressOf ImageClickHandler cellleft.Controls.Add(imgholi) buttoncreated = True Session("ButtonCreated") = buttoncreated
i have 3 calendars(Daily, weekly, monthly). If i were to select the daily calendar and click on the imagebtn, the table refreshes unless i select the weekly calendar and click the imgbtn. why? -
Well, yes... I'm not certain which snippet you're referring to, but in general, bear in mind that you're writing code that responds to particular events and each control event is independent of others on the same page, except for the page level events, that fire each time the page loads or posts. So, if, for example, I write an event handler for a button that creates a checkbox dynamically and stores some indication of that in Session, and later on I write an event handler that responds to the click event of another control that also dynamically creates something, I have to store some other indicator of that in Session as well, and so on, for each thing that I do. Do you see? If need be, I can point to the places in MSDN that describe the sequence of events and ASP session or state management. 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.
BIG BIG PROBLEM! Any idea what error is this? An error has occurred because a control with auto-generated id '_ctl4' could not be located to raise a postback event. To avoid this error, explicitly set the ID property of controls that raise postback events. When the page is loaded the first time, everything is fine. However, when i click next, to show other day of the event calendar, It create TWO calendars instead of 1. Why is this so?
Dim buttoncreated As Boolean = CType(Session("ButtonCreated"), Boolean) If IsPostBack Then If Not buttoncreated Then createCalendar() End If End If Session("ButtonCreated") = buttoncreated (in page load)
Public Sub createCalendar() If Not statuscheck = 0 Then Dim img As New ImageButton img.ID = rid Session.Add("ButtonClick", imgResource) 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
createcalendar() is called each time user click on BUTTON GO. -
Well, yes... I'm not certain which snippet you're referring to, but in general, bear in mind that you're writing code that responds to particular events and each control event is independent of others on the same page, except for the page level events, that fire each time the page loads or posts. So, if, for example, I write an event handler for a button that creates a checkbox dynamically and stores some indication of that in Session, and later on I write an event handler that responds to the click event of another control that also dynamically creates something, I have to store some other indicator of that in Session as well, and so on, for each thing that I do. Do you see? If need be, I can point to the places in MSDN that describe the sequence of events and ASP session or state management. 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.
BIG BIG PROBLEM! Any idea what error is this? An error has occurred because a control with auto-generated id '_ctl4' could not be located to raise a postback event. To avoid this error, explicitly set the ID property of controls that raise postback events. When the page is loaded the first time, everything is fine. However, when i click next, to show other day of the event calendar, It create TWO calendars instead of 1. Why is this so?
Dim buttoncreated As Boolean = CType(Session("ButtonCreated"), Boolean) If IsPostBack Then If Not buttoncreated Then createCalendar() End If End If Session("ButtonCreated") = buttoncreated (in page load)
Public Sub createCalendar() If Not statuscheck = 0 Then Dim img As New ImageButton img.ID = rid Session.Add("ButtonClick", imgResource) 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
createcalendar() is called each time user click on BUTTON GO. -
Well, yes... I'm not certain which snippet you're referring to, but in general, bear in mind that you're writing code that responds to particular events and each control event is independent of others on the same page, except for the page level events, that fire each time the page loads or posts. So, if, for example, I write an event handler for a button that creates a checkbox dynamically and stores some indication of that in Session, and later on I write an event handler that responds to the click event of another control that also dynamically creates something, I have to store some other indicator of that in Session as well, and so on, for each thing that I do. Do you see? If need be, I can point to the places in MSDN that describe the sequence of events and ASP session or state management. 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.
What is the cause for this error? I have assigned a unique ID to each controls. An error has occurred because a control with auto-generated id '_ctl26' could not be located to raise a postback event. To avoid this error, explicitly set the ID property of controls that raise postback events. How i can get the value of which iamgebutton is click. i need to pass the value to another form when click.
-
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.
If Not Session("ButtonCreated") Is Nothing Then buttoncreated = CType(Session("ButtonCreated"), Boolean) Else buttoncreated = False End If If IsPostBack And buttoncreated Then ' calEvent_DayRender() ' createcalendar() End If
How can i apply this to monthly calendar? i make sure of the calendar control method-dayrender. I cant possible just code the sub just like what i did for the other calendar -createcalendar() -
If Not Session("ButtonCreated") Is Nothing Then buttoncreated = CType(Session("ButtonCreated"), Boolean) Else buttoncreated = False End If If IsPostBack And buttoncreated Then ' calEvent_DayRender() ' createcalendar() End If
How can i apply this to monthly calendar? i make sure of the calendar control method-dayrender. I cant possible just code the sub just like what i did for the other calendar -createcalendar()Which part -- the DayRender event or the CreateCalendar method or the setting of a session variable to indicate something already done? 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.
-
What is the cause for this error? I have assigned a unique ID to each controls. An error has occurred because a control with auto-generated id '_ctl26' could not be located to raise a postback event. To avoid this error, explicitly set the ID property of controls that raise postback events. How i can get the value of which iamgebutton is click. i need to pass the value to another form when click.
When you create a control, give it an ID. When you re-create it, give it the same ID. 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.
-
Which part -- the DayRender event or the CreateCalendar method or the setting of a session variable to indicate something already done? 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.
-
Which part -- the DayRender event or the CreateCalendar method or the setting of a session variable to indicate something already done? 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 DayRender event. The imagebuttons are created in this event. So what can i do so i can call this on isPostBack. Like what I have before is the createcalendar() which can be apply to postback and creating the calendar on first load.
Right, I'd try the same thing. So, you would have one method callable from wherever you choose that would create a new image button in a container:
Private Function CreateImageButton(...) As ImageButton
' ...
End FunctionPrivate Sub Calendar_DayRender(...) Handles Calendar.DayRender
' ...
e.Controls.Add(CreateImageButton(...))
End SubPrivate Sub ReCreateImageButtons(...)
For i As Integer = 1 To MyNumberOfControls
something.Controls.Add(CreateImageButton(...))
Next
End SubOf course, this is just a rough sketch... I don't have enough time right now to write real code and make sure that it works. I wrote this in the "Text" window of CodeProject, not in VS or anything... 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 part on creating the dynamic button on page postback. The day_render is an event unlike the createcalendar() where i can place it anywhere. day_render require parameter
So, also try creating new values in Session() that indicate whether or not another something or other has already been created and needs to be recreated on post-back. 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, I'd try the same thing. So, you would have one method callable from wherever you choose that would create a new image button in a container:
Private Function CreateImageButton(...) As ImageButton
' ...
End FunctionPrivate Sub Calendar_DayRender(...) Handles Calendar.DayRender
' ...
e.Controls.Add(CreateImageButton(...))
End SubPrivate Sub ReCreateImageButtons(...)
For i As Integer = 1 To MyNumberOfControls
something.Controls.Add(CreateImageButton(...))
Next
End SubOf course, this is just a rough sketch... I don't have enough time right now to write real code and make sure that it works. I wrote this in the "Text" window of CodeProject, not in VS or anything... 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.
But mine day render code make use of the parameter e.
Private Sub calEvent_DayRender(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles calEvent.DayRender Dim yr As Integer = lblyear.Text Dim r As String 'lblmthSelect.Text = "3" Dim mth As String = lblmthSelect.Text Dim countloop As Integer = 0 Dim imgicon As System.Web.UI.WebControls.Image e.Day.IsSelectable = False If e.Day.IsOtherMonth Then e.Cell.Controls.Clear() e.Cell.Dispose() End If lblInstructions.Visible = False ' calEvent.Visible = True Dim i, j, num, k, b As Integer Dim rname As String Dim bkresource, bkInfo As DataSet Dim own As DataSet Dim txt As String Dim starting As Integer For i = 0 To cbxlistResource.Items.Count - 1 If cbxlistResource.Items(i).Selected = True Then countloop += 1 Dim number As Integer = 0 Dim row As New TableRow Dim cellleft As New TableCell Dim cellright As New TableCell Dim lblnametxt As New Label Dim divlbl As New Label rname = cbxlistResource.Items(i).Text Dim rstart As New Regex("~") Dim mstart As Match = rstart.Match(rname) If mstart.Success Then starting = mstart.Index.ToString() End If Dim totlen As Integer = rname.Length - starting Dim result As String = rname.Substring(starting, totlen) Dim totfinal As Integer = result.Length - 2 Dim finalresult As String = result.Substring(2, totfinal) Dim name As String = eresource.remove(finalresult, "(") Dim rID As String = eresource.getResourceID(name) '============= to retrieve resource owned by =============== own = eresource.getresourceownby(rID) For k = 0 To own.Tables(0).Rows.Count - 1 Dim ownccode As String = own.Tables(0).Rows(k).Item(0) Dim ownCname As String = eresource.getCNameByCC(ownccode) Dim ownDiv As String = own.Tables(0).Rows(k).Item(1) Dim resourcename As String = own.Tables(0).Rows(k).Item(2) txt = " " & ownCname
-
But mine day render code make use of the parameter e.
Private Sub calEvent_DayRender(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles calEvent.DayRender Dim yr As Integer = lblyear.Text Dim r As String 'lblmthSelect.Text = "3" Dim mth As String = lblmthSelect.Text Dim countloop As Integer = 0 Dim imgicon As System.Web.UI.WebControls.Image e.Day.IsSelectable = False If e.Day.IsOtherMonth Then e.Cell.Controls.Clear() e.Cell.Dispose() End If lblInstructions.Visible = False ' calEvent.Visible = True Dim i, j, num, k, b As Integer Dim rname As String Dim bkresource, bkInfo As DataSet Dim own As DataSet Dim txt As String Dim starting As Integer For i = 0 To cbxlistResource.Items.Count - 1 If cbxlistResource.Items(i).Selected = True Then countloop += 1 Dim number As Integer = 0 Dim row As New TableRow Dim cellleft As New TableCell Dim cellright As New TableCell Dim lblnametxt As New Label Dim divlbl As New Label rname = cbxlistResource.Items(i).Text Dim rstart As New Regex("~") Dim mstart As Match = rstart.Match(rname) If mstart.Success Then starting = mstart.Index.ToString() End If Dim totlen As Integer = rname.Length - starting Dim result As String = rname.Substring(starting, totlen) Dim totfinal As Integer = result.Length - 2 Dim finalresult As String = result.Substring(2, totfinal) Dim name As String = eresource.remove(finalresult, "(") Dim rID As String = eresource.getResourceID(name) '============= to retrieve resource owned by =============== own = eresource.getresourceownby(rID) For k = 0 To own.Tables(0).Rows.Count - 1 Dim ownccode As String = own.Tables(0).Rows(k).Item(0) Dim ownCname As String = eresource.getCNameByCC(ownccode) Dim ownDiv As String = own.Tables(0).Rows(k).Item(1) Dim resourcename As String = own.Tables(0).Rows(k).Item(2) txt = " " & ownCname
Well... one of the original principles of structured programming is that you can and should break large tasks down into smaller tasks, and each task -- a function or a procedure ("sub" in VB.NET) -- can have parameters passed by the calling procedure. So, in this case, you could create one or more subs or functions, either with the "e" as a parameter, or one or more subs or functions that take as their parameter(s) a value of a property of "e":
Private Function DoSomething(ByVal e As DayRenderEventArgs) As Label
' ...
End Functionor,
DoSomethingElse(e.Day.IsOtherMonth)
Private Sub DoSomethingElse(ByVal isOtherMonth As Boolean)
' ...
End SubOK? 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.