 |
|
 |
Would I have to rewrite your TextLengthValidator.cs to be used where my sites codebehind is VB or is there a way to use as is?
Thanks, and good job, I've been looking for this.
Luke
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You'd be able to use is as it but you would need to compile it into a dll then add it as a reference to your project.
SuzyB
<i>If I had a better memory I would remember more.</i>
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Greetings!
Many thanks for a component, it very useful. Unique improvement which I can advise - to store JavaScript in resources instead of in a separate file. It is more convenient, and not necessary to spread a file of a script on a site.
Igon
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Thanks for this article. It helped me building my own custom validator, where I use it to detect that the text entered is between a min and max value. I also included the javascript inside the .cs file instead of a separate .js file. Saves a little I/O action.
here's an example of how I included the JavaScript within the .cs file:
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e);
if (RenderUplevel) { String scriptKey = typeof(TextLengthValidator).FullName; // Only register the script if it has not already been registered if (!Page.IsClientScriptBlockRegistered(scriptKey)) { Page.RegisterClientScriptBlock(scriptKey, JavaScript()); } } }
protected String JavaScript() { StringBuilder scriptText = new StringBuilder();
scriptText.Append(@"<script language=""javascript"">"); scriptText.Append("function TextLengthValidator(val)"); scriptText.Append("{"); scriptText.Append("// The javascript should go here"); ... [JavaScript function] ... scriptText.Append("}"); scriptText.Append("</script>");
return scriptText.ToString(); }
P.S. for .NET 2.0 change
if (!Page.IsClientScriptBlockRegistered(scriptKey)) { Page.RegisterClientScriptBlock(scriptKey, JavaScript()); }
into
if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptKey)) { Page.ClientScript.RegisterClientScriptBlock(GetType(), scriptKey, JavaScript()); }
Thanks again for a nice introduction and I also liked the regular expressions remark! -Anne
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
|
 |
|
 |
i need textbox first letter to be capital and text box only accept number, plus sign,hyphen,parathesis. with out using user controls
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
i need 1)textbox first letter to be capital 2)text box only accept number, plus sign,hyphen,parathesis. with out using user controls
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
i need 1)textbox first letter to be capital 2)text box only accept number, plus sign,hyphen,parathesis.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
I get the following message.
Parser Error Message: File or assembly name Web.Controls, or one of its dependencies, was not found.
Source Error:
Line 1: <%@ Register TagPrefix="controls" Namespace="Web.Controls" Assembly="Web.Controls" %>
I suspect that the problem is the WithEvents is missing. This line of code doesn't work.
Protected WithEvents TextLengthValidator As System.Web.UI.WebControls.TextLengthValidator
Can someone help? Thank you.
RK
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Multiline Textboxe Length can be validated by using RegularExpressionValidator
The Resular Expression would be ^.{0,500}$ where 500 is the max limit of chars
Thank Usman
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
 |
This is a much easier approach than using the often buggy custom validator. Thanks for the idea. I'm using it and it work great.
-- Mike
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Thanks! that little regular expression just saved me 3 sevaral lines of javascript emmission on the pages i'm working on.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
...to get around the textbox ignoring maxlength, include the following in the html tag of the textbox. onkeyup="javascript: this.value = this.value.substring(0, 199);"
(199 obviously varies by desired maxlength)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
this one doesn't work with me, how come?
I tried :
<asp:TextBox id="Textbox1" runat="server" width="123" textmodus="multiline" onkeyup="javascript this.value=this.value.substring(0,10);"></asp:TextBox>
Anyone have an idea?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
'onkeyup' is a client side object event, not an event/property of a server-side ASP.NET Textbox. For the javascript to work it has to be added to the client-side control. Either add it using client-side javascript directly or you can add it to the server-side control's 'attribute' property, such as:
Textbox1.Attributes["onkeyup"]="this.value = this.value.substring(0,10)";
Note that in my opinion its better to use "onkeydown" (prevents the character to be displayed in the first place).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
My company do not provide me a Visual Studio.NET so that I find that I cannot install that control. I follow the steps (insert the <%@ Register ... > and insert the ). Also I copy the source files downloaded at the same directory with my aspx file.
But it end up display error message that it did't find the Web.Controls component. What's the matter? Thank you.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The source needs to be compilied into a dll and placed in the bin folder of the website.
If I had a better memory I would remember more.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Very nice. Had been using this one previously: http://www.fluentconsulting.com/components/Fluent.MultiLineTextBoxValidator/ which does a nice job as well as it shows a character count in real time. Might consider adding that 
Oh, what doesn't seem to work is adding the 'CssClass' and 'ErrorMessage' to the control. Although it is a validator that part doesn't work yet. Personally I need the 'ErrorMessage' for my 'ValidationSummary' on the page.
Nice job, best of luck,
Danny Webengineer.nl
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I was going to add a character count but I'm not that great at javascript and couldn't get it to work so I took it out. I'll maybe have another go sometime when I get some free time.
What is it that is not working with the 'CssClass' and 'ErrorMessage'. I quickly tried it when I read your post but it seemed to work OK.
If I had a better memory I would remember more.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi Danny.
You mentioned that you used the Fluent version of the multiline textbox validator.
I tried to implement that one and got a null ref exception. Fluent MultiLineTextBoxValidator ApplicationException: Control referenced by "ControlToValidate" (TestTextBox) could not be found.]
Where TestTextBox is the name of my TextBox.
I saw some other folks had this error, but the thread was in Danish, which I don't speak.
Any help would be much appreciated.
E
|
| Sign In·View Thread·PermaLink | 2.00/5 (3 votes) |
|
|
|
 |