| | |
Help in converting ASP.net Vb code to ASP.net C# code + Custom validator
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 75
Reputation:
Solved Threads: 0
I have one custom validator, one textbox & one button..I m checking the length of data entered in textbox.
VB CODE
When i click on button,page is postbacked,if the length is less than 8 error msg comes,else nothing.
Mine C# Equivalent code-
ERROR - The name 'len' does not exist in the current context
VB CODE
ASP.NET Syntax (Toggle Plain Text)
<asp:CustomValidator ID="CustomValidator1" runat="server" OnServerValidate="ValidateThis" ErrorMessage="The username must be 8" ControlToValidate="TextBox4"></asp:CustomValidator></td>
ASP.NET Syntax (Toggle Plain Text)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub ValidateThis(ByVal Sender As Object, ByVal args As _ ServerValidateEventArgs) If Len(args.Value) < 8 Then args.IsValid = False Else args.IsValid = True End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
When i click on button,page is postbacked,if the length is less than 8 error msg comes,else nothing.
Mine C# Equivalent code-
ASP.NET Syntax (Toggle Plain Text)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat ="server" > void ValidateThis(object Sender,ServerValidateEventArgs args) { if(len(args.Value)< 0) { args.IsValid = false; } else args.IsValid = true ; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
ERROR - The name 'len' does not exist in the current context
•
•
Join Date: Jul 2009
Posts: 19
Reputation:
Solved Threads: 3
ASP.NET Syntax (Toggle Plain Text)
<script runat="server"> void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { if (args.Value.Length < 8) { args.IsValid = false; } else { args.IsValid = true; } } </script>
try this ......
Chithra
![]() |
Similar Threads
- ASP.NET button backcolor changing from code. (ASP.NET)
- ASP.NET/SQL Developer/Programmer (Web Development Job Offers)
- Moving VB.NET Code to ASP.NET Code? (ASP.NET)
- Is it possible to execute the ASP.NET code in command prompt..? (C#)
- Free ASP.NET Application with code to practice (ASP.NET)
- I Need Sample ASP.NET Code (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Emailing from a simple web application
- Next Thread: Hosting of ADO.Net Data Services, but changes $value to a file download
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dialog dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis image javascript list listbox login microsoft mono mouse mssql multistepregistration news numerical opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





