textbox inside calendar?

R

rc

Hello,



Trying to place a textbox for each day inside a calendar control using code
triggered from the RenderDay method to fill each cell.



The following code, using a standard HTML input box, works fine:



//

Sub Cal_RenderDay(s as object, e as DayRenderEventArgs)

e.cell.text="<center><b>" & Day(e.day.date) & "</b><BR><INPUT
NAME='Day" & Day(e.day.date) & "'

MAXLENGTH='5' SIZE='3' ></center>"

end sub

//



However, if I try to replace the HTML textbox with an asp:textbox, like
this:



//

Sub Cal_RenderDay(s as object, e as DayRenderEventArgs)

e.cell.text="<center><b>" & Day(e.day.date) & "</b><BR><asp:textbox
id='Day" & Day(e.day.date) & "' columns='3' maxlength='5'
runat='server'/></center>"

end sub

//



the calendar looks fine, but no text boxes rendered.



Any insight would be helpful.



Thank you
 
C

Cirrosi

You cannot do like this.
Try

Sub Cal_RenderDay(s as object, e as DayRenderEventArgs)
TextBox tb=new TextBox()
tb.attributes("name")="Day" & Day(e.day.date)
tb.Text=Day(e.day.date)
.....
e.Cell.Controls.Clear()
e.Cell.Controls.Add(tb)
end sub


I have not try it, but i tink it's the rigth way.

Excuse me for my bad english.
 
R

rc

Thanks for the reply



It works GREAT!!!!



Now, is it possible to add a rangevalidator control to each textbox?



This is what I have so far:



Sub Calendar_RenderDay(s as object, e as DayRenderEventArgs)



dim lb=new label()

dim tb=new TextBox()



lb.text="<center><b>" & Day(e.day.date) & "</b><BR>"



tb.id="Day" & Day(e.day.date)

tb.columns="2"

tb.maxlength="3"



e.Cell.Controls.Clear()

e.Cell.Controls.Add(lb)

e.Cell.Controls.Add(tb)



end sub





Thanks again for your help.
 
C

Cirrosi

Yes, you can add a RangeValidator to Page.Controls in the same way, set the
required properties and set the id like the text id you created in
Calendar_RenderDay.

I hope it's comprensible.
 
R

rc

Well, I must be using the wrong syntax, because it's not rendering
correctly.



Here is how I'm adding the control.

//

dim rv=new RangeValidator()



rv.id="RV" & Day(e.day.date)

rv.text="*"

rv.ControlToValidate="Day" & Day(e.day.date)

rv.MaximumValue="212"

rv.MinimumValue="0"

rv.Type = ValidationDataType.Integer



e.cell.Controls.Add(rv)

//





Do you see anything wrong with this?



Any help would be appreciated.





Thanks for all your help.
 

kle

Joined
May 15, 2008
Messages
1
Reaction score
0
How to access the text box after you generated in side the calendar

Hi I read through the thread, however, could you let me know once we have successfully generate the text box inside the calendar. Then how do you get the data out of the text box. Please response as I need to complete my project by this weekend.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top