About the author

Vijay Kodali
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Multiline Asp.Net textbox maxlength

MaxLength property of a TextBox control does not work when the TextMode property is set to Multiline. Here is small work around using regualr expression validator..

<asp:TextBox ID="txtComment" runat="server" Width="466px" TextMode ="MultiLine" ></asp:TextBox> 
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtComment" 
ErrorMessage="Not more than 50 charcters" Display="Static" ValidationExpression='^[\s\S]{0,50}$'> 
</asp:RegularExpressionValidator> 

Tags:
Categories: ASP.NET
Posted by vijay on Wednesday, November 21, 2007 3:02 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Page cannot be displayed error with Asp.Net FileUpload

 The File Upload server control provided by ASP.NET allows users to upload one or more files to the server. By default, ASP.NET permits only files that are 4,096 KB (or 4 MB) or less to be uploaded to the Web server. To upload larger files, you must change the maxRequestLength parameter of the <httpRuntime> section in the Web.config file.


<system.web>
  <httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>  

 The value of maxrequestlength is in KB. In this case it's allowed up to 20 MB


Categories: ASP.NET
Posted by vijay on Friday, November 16, 2007 3:13 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Java Script function to only allow integers in the textbox

Here is sample code for TextBox Validation to allow Numbers only.

[code:c#]

<script type = "text/javascript" language = "javascript">

function CheckTextBox(i)
{
    if(i.value.length>0)
    {
    i.value = i.value.replace(/[^\d]+/g, '');
    }
}

</Script>

[/code]

In Code behind add this function to "onkeyup" event for TextBox

[code:c#]

TextBox1.Attributes.Add("onkeypress", "CheckTextBox(this)");

[/code]


Posted by vijay on Wednesday, November 14, 2007 7:54 PM
Permalink | Comments (0) | Post RSSRSS comment feed