|
-
Oct 10th, 2005, 06:52 AM
#1
Thread Starter
Fanatic Member
[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
-
Oct 10th, 2005, 07:59 AM
#2
Member
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.
-
Oct 10th, 2005, 08:28 AM
#3
Thread Starter
Fanatic Member
Re: Set MaxLength on form Load
Basilisk,
Thanks for that, just wasted the whole morning trying to get it working.
Cheers Al
-
Oct 10th, 2005, 01:46 PM
#4
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 - " -.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 10th, 2005, 03:18 PM
#5
Thread Starter
Fanatic Member
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
Cheers Al
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|