[RESOLVED] Set MaxLength on form Load
Hi,
Does anyone know how to populate the maxlength property of an asp:textbox on page load?
I'm getting the value from the my config table in my DB
When I try setting myControl.MaxLength=10 in the onload event
It's not written to the control and when I enter text I'm not restricted at all
I've also tried
VB Code:
<asp:textbox id="Abstract" Runat="server" Wrap="True" Rows="11" Columns="45" TextMode="MultiLine" maxlength="[HL="#FFFF00"]<%=SummaryLimit%>[/HL]"></asp:textbox>
' And
<asp:textbox id="Abstract" Runat="server" Wrap="True" Rows="11" Columns="45" TextMode="MultiLine" maxlength="[HL="#FFFF00"]<%=Convert.ToInt32(SummaryLimit)%>[/HL]"></asp:textbox>
Geting error - <%=SummaryLimit%> is not a valid value for Int32.
And
<%=Convert.ToInt32(SummaryLimit)%> is not a valid value for Int32.
SummaryLimit Value is declared and assigned as an Int32
VB Code:
Dim m_iSummaryLimit As Int32 = 250
Public Property SummaryLimit() As Int32
Get
Return Convert.ToInt32(m_iSummaryLimit)
End Get
Set(ByVal Value As Int32)
m_iSummaryLimit = Convert.ToInt32(Value)
End Set
End Property
Re: Set MaxLength on form Load
The textbox control when in multiline mode actually renders as a HTML textarea therefore on a textarea there is no maxlength property so maxlength does not work. One of the ways to control this is to use javascript instead.
Re: Set MaxLength on form Load
Basilisk,
Thanks for that, just wasted the whole morning trying to get it working.
Cheers Al
Re: [RESOLVED] Set MaxLength on form Load
I did want to pipe in and say that when you use the following:
<%= ... %>
in an item tag, you need to surround it with single quotes - ' - and not double quotes - " -.
Re: [RESOLVED] Set MaxLength on form Load
Lord Rat,
Thanks, feel free to pop out of your cave with useful tips like that at anytime :D
Cheers Al