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.
 

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

Top