Friday 28 September 2012

Validation Controls in ASP.net

ASP.Net provides validation controls which a rich amount
of validation services that saves your work to make
java script code because at a huge level java script is used to validate client side
validation. for perform validation using java script you must have knowledge of
java script.
But you can perform powerful validation using ASP.net Validation
Controls with knowledge of java script..

RequiredFieldValidator Control

Evaluates the value of an input control to ensure that the user enters a value.
Use the RequiredFieldValidator control to make an input control a mandatory field. The input control fails validation if the value it contains does not change from its initial value when validation is performed. This prevents the user from leaving the associated input control unchanged. By default, the initial value is an empty string (""), which indicates that a value must be entered in the input control for it to pass validation.

Controls :
  • Textbox
  • ASP Button
  • Requirefield Validater
  • Label
Property :
         RequiredFieldValidator
  • ControlToValidate="TextBox1"
  • ErrorMessage="*" 
Aspx page code 
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
            ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save" />
<asp:Label ID="Label1" runat="server"></asp:Label> 
</form>

Server Side code :
protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "Running Server code";
    }


RangeValidator Control 


Evaluates the value of an input control to determine whether it is between the specified upper and lower boundaries.
The RangeValidator control allows you to check whether a user's entry is between a specified upper and a specified lower boundary. You can check ranges within pairs of numbers, alphabetic characters, and dates. Boundaries are expressed as constants.

Print a character in Notepad,Excel,Power Point using ASCII code

Notepad is windows platform text editor.
You can enter value in notepad within a ASCII range
but You can also provide input using ASCII code
because keyboard has not all key which can print all ASCII Code
Steps 
  • Press ASCII character with alt key
  • make sure num lock is on
  • because you can provide ASCII only using numeric key......

How to make Numeric,String textbox and many more on a webpage using java script

Here i'm showing code which help you to make
a textbox which can only accept number.
This is helpful when you're making texbox which takes number as input
This solution works in both IE and Mozilla.
Numeric  Textbox..
HTML Code :
<html>
<head >
    <title>Girfa Numeric Textbox Demo</title>
   
    <script language="javascript">
        function validatenumber(evt)
        {
           
          var ch = (evt.which) ? evt.which : event.keyCode
          if(ch > 31 && (ch < 48 || ch > 57))         
            return false;
                   
          return true;                     
            
        }

Thursday 27 September 2012

How to make popup menu in VB 6.0

Hi...
Popup menu is menu which appeared when we right click from mouse
on a form. You can see it when you right click on desktop a menu appeared
which is pop menu.
There're many uses of popup menu in windows development
Popup menu provide many flexible option front of user its really make
an application more user friendly because user choose their option frequently


   as you can see in image that you must make a menu and make it visible property false
otherwise it'll not appear on form.
You have to visible it on mouse right click . So we can use form mouse up event.
For Detect right click button of mouse you can use Button value which initialize by event handler
if button value is 2 then its rdenotes right click otherwise 1 if user clicked on left button
Now you can make its visibility true as in code....

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
        PopupMenu mnedit
    End If
 
End Sub