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
<asp:textbox id="Abstract" Runat="server" Wrap="True" Rows="11" Columns="45" TextMode="MultiLine" maxlength="<%=SummaryLimit%>"></asp:textbox>
' And
<asp:textbox id="Abstract" Runat="server" Wrap="True" Rows="11" Columns="45" TextMode="MultiLine" maxlength="<%=Convert.ToInt32(SummaryLimit)%>"></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
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 PropertyThe 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.
Basilisk,
Thanks for that, just wasted the whole morning trying to get it working.
Cheers Al
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 - " -.
Lord Rat,
Thanks, feel free to pop out of your cave with useful tips like that at anytime :D
Cheers Al
0 comments:
Post a Comment