Monday, April 30, 2012

A network-related or instance-specific error

In previous articles i have explained  login failed for user 'sa' in sql server,.This is the common error will occur while establishing a connection to sqlserver. To resolve this problem we need to change network configuration  settings.Here i will explain how to change remote connection settings in configuration area .First we need to check the given data source name is correct or not in connection string.The TCP/IP protocol should be enable to made such type connection.The following steps will describe how to enable TCP/IP protocol in sql server configuration manager
Go To-->Configuration Tools folder which is in MS Sql Server 2008 folder in start menu
2.Select server Network configuration-->click on protocols for SQLEXPRESS.
Then we can see the protocols at Right side panel.By default the TCP/IP status is in disable mode.So we need to change status to enable


Sunday, April 29, 2012

How the item is active based on position in xml using xslt

Here i will show how to create position  based div's from XML data source using xslt.The XML data source has parent attribute with three items .There is on click function to make the selected div as active .By default we will set the first items as active link

<?xml version="1.0" encoding="utf-8" ?> 
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
<div>
- <ul>
- <xsl:for-each select="Menu/Item">
- <xsl:if test="ItemType != 'Javascript'">
- <li>
- <xsl:if test="position() = 1">
- <xsl:attribute name="class">
  <xsl:text>active</xsl:text>
  </xsl:attribute>
  </xsl:if>
- <a title="" onclick="return false;">
- <xsl:attribute name="href">
- <xsl:choose>
- <xsl:when test="position() = 1">
  <xsl:text>#stories</xsl:text>
  </xsl:when>
- <xsl:when test="position() = 2">
  <xsl:text>#events</xsl:text>
  </xsl:when>
- <xsl:when test="position() = 3">
  <xsl:text>#news</xsl:text>
  </xsl:when>
  </xsl:choose>
  </xsl:attribute>
  <xsl:value-of select="ItemTitle" />
  </a>
  </li>
  </xsl:if>
  </xsl:for-each>
  </ul>
</div>
  </xsl:template>
  </xsl:stylesheet>

Saturday, April 28, 2012

Postback forms in asp.net

It is a concept of html forms only when a form itself in its submission then we call this form/page as post back form/page. The basic question will be arise when we going thorough the postback concepts.How asp.net is related to this post back forms? If we create asp.net form we don't provide any action attribute to it. manually also it is not recommended to write action methods.
                               During rendering asp.net automatically writes action attribute which will call the some form or page name every asp.net form is a post back form. One more thing we have to know i:e why asp.net forces this post back concept.One of the main reason is to provide state management for page and its controls

 Note:- In asp.net 1.0/1.1 they was the only concept for post backs i:e straight post backs.Form asp.net 2.0 we can Even perform cross page post backs.Default is straight post back only

Friday, April 27, 2012

pass variable from codebehind to aspx (client side) in asp.net || pass value from server side to client side in Asp.net

In previous post i have given how to pass the variable value from client side  to server side (code behind).Now i will show how to pass the variable from code behind to aspx .Here i would not use any javascript or etc.Because there is so many ways to get the values to javascript variables from code behind.This process easy to understand for developers and who has not much knowledge in javascript.
<form  method="post" action="Calculation.aspx">
    <input id="h1" type="hidden" name="cart"  value="<%=strEncoded %>"/>
    <input id="h2" type="hidden" name="signature" value="<%=sign %>"/>
    <input type="button" name="submit"/>
</form>
When ever we assign the values to html control ,Those should be declare as "public" variable.Here the strEncoded,sign are passed to client side using "<%= >"
 public String strEncoded;
 public string sign;
//page_load
 strEncoded = "Encode string";
 sign= "teststring";

Thursday, April 26, 2012

Get the List of calendar events in ektron cms

The ektron calendar provides an easy ways to site admin to add,edit and update the events for calendar year or more.Here i will show how to get the calendar events list to list view.Using Web calendar API ,i will send the calendar id ,start date and end date as input parameters to get the list items between data range.Here the method Getlist() which will give the list of calendar events
 Ektron.Cms.Controls.Calendar c = new Ektron.Cms.Controls.Calendar();
 WebEventManager wManager = new WebEventManager();
 //calendar id in Workarea
 long calId = 1654;
 String st = DateTime.Now.ToString();//cuurent date
 String et = "31-04-2012 17:30:00";
 DateTime startdate= DateTime.Parse(st);
 DateTime enddate = DateTime.Parse(et);
 List webeventcalendarList = wManager.GetList(calId,startdate,enddate);
 if (webeventcalendarList != null)
{
list_events.DataSource = webeventcalendarList;
list_events.DataBind();
}
 else
{
Response.Write("There is no list of events");
}

Wednesday, April 25, 2012

How to Get all xml Items using xslt

Before doing this task i don't have an idea about xslt .Xslt is easy to learn and  to develop. Here i will show how to get the all XML items and display the items as list of anchor at client side view.For this i will use for loop to get the XML data

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">  
    <xsl:template match="/">
        <xsl:for-each select="List/Item">           
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>#</xsl:text>
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:text>Title</xsl:text>
                    </xsl:attribute>
                    <xsl:attribute name="target">
                        <xsl:text>blank</xsl:text>
                    </xsl:attribute>                   
                    <img>
                        <xsl:attribute name="src">
                            <xsl:value-of select="href"/>
                        </xsl:attribute>
                        <xsl:attribute  name="alt">
                            <xsl:value-of select="Title"/>
                        </xsl:attribute>
                        <xsl:attribute  name="class">
                            <xsl:text>slider_img</xsl:text>
                        </xsl:attribute>
                    </img>
                    <span>
                        <b>
                            <xsl:value-of select="Title"/>
                        </b>                       
                        </span>
                </a>               
        </xsl:for-each>    </xsl:template>  
</xsl:stylesheet>

Tuesday, April 24, 2012

Email Validation in asp.net

Basically we can do different type validation in asp.net which are client side and server side email validation.The client side validation has done using jquery,javascript and asp.net validation controls.Right now i will show how to perform the server side validation using regex patterns. Pattern for email:
public const string EmailPattern =
            @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
     + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
    [0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
     + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
    [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
     + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

note 1:Parameter-string that contains an E-Mail address.
note 2:True, when Parameter-string is not null and 
note 3: contains a valid E-Mail address;
note 4:otherwise false.

public static bool IsEmail(string email)
{
if (email != null) return Regex.IsMatch(email, MatchEmailPattern);
else return false;
}
The below function will call the valid email function which is "IsEmail", when we submit the email text box data
if (!IsEmail(email.Text))
{
strError += "Please enter a valid email address";
isValid = false;
}

Monday, April 23, 2012

How to connecting to SQLserver from asp.net application

Title: How to create connection string in asp.net using C#.net

Description:
If you want to connect with SQLServer from asp.net application ,you can either use the OLEDB class as well as SQL Client classes.While connecting with OLEDB Connection to mention the target data source we specify the name of the provider which has be to be used.But when you use SQL connection or Oracle connection classes the connection string does not require the provider name to be specified.Here i will show an example to get the data from database using connection object

Example
Using system.Data.SqlClient
SqlConnection cn;
SqlCOmmand cmd;
SqlDataReader dr;
under page load
cn=New SqlConnection("user id=sa;password=123;Database=asp.net");
cmd=New SqlCommand("select*from students",cn);
cn.open();
dr=cmd.ExcuteReader();
if(dr.Read())
{
Response.Write(dr[0].Tostring());
}

Sunday, April 22, 2012

How to binding data to Dropdown list in asp.net

In previous post i explained how to bind data to grid view in asp.net,bind data to dropdownlist in Asp.net mvc,Gridview paging and sorting,Jquery dropdownlist selected value.Here i will describe how to bind the data to drop down list in asp.net.The "ddlcity is id of the drop down list.The function "Loadddlcity()" which is return the data of city as data table.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Bind data to dropdownlist in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList ID="ddlOrdr" runat="server">
</asp:DropDownList>
</form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.SqlClient;
using System.Data;
public partial class DropdownBind : System.Web.UI.Page
{
SqlConnection Orcon = new SqlConnection(ConfigurationManager.AppSettings["OrdrCon"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
 dTable =Loadddlcity();
 ddlOrdrcity.DataTextField = "cityname";
 ddlOrdrcity.DataValueField = "cityid";
 ddlOrdrcity.DataSource = dTable;
 ddlOrdrcity.DataBind();
public DataTable Loadddlcity()
 {
 con.Open();
 try
 {
oda = new SqlDataAdapter("select*from city",Orcon);
oda.Fill(ods, "citymaster");
return ods.Tables["citymaster"];
 }
catch
 {
 throw;
 }
finally
 {
 cmd.Dispose();
 Orcon.Close();
 Orcon.Dispose();
 }
}

Saturday, April 21, 2012

indexes in sql server

By using index: it will traverse through the index tree structure to find the required data and extract the data that satisfy the query criteria.


Indexes: indexes in sql server are similar to index in a book. Indexes are used to improve the performance of quires.
Indexes are generally created for following columns.
1). Primary key column
2). Foreign key column: Frequently used in join conditions
3). Column which are frequently used in where clause
4). Columns which are used to retrieve the data in sorting order
Indexes are cannot be created for following columns
The columns which are not frequently used in where clause.
Columns containing the duplicate and NULL values.
Columns containing images, binary information, and text information.
Types of indexes
1). Clustered index
2). Non-clustered index
3). Unique index
4). Composite index
1). Clustered index: Only one clustered index is allowed for a table. The order of values in a table. Order of values in index is also same. When cluster index is created on table data is arranged in ascending order cluster index will occupy 5% of the table.
Syntax:
Create clustered index <index_name> an <table_name> (columns)
Create clustered index emp_clindex an emp (empno)
2). Non-clustered index:
It is the default index created by the server the physical order of the data in the table is different from the order of the values in index.
Max no of non – clustered indexes allowed for table is 249.
Syntax:
Create non-clustered index <index_name> on table_name <columns>
Create non-clustered index emp_sal on emp (deptno, sal)

3). Unique index:
An index with unique constraint. It will not allow duplicate values.
Syntax:
Create unique index <index name> on <tablename> (column)
Create unique index dept_index on dept (dname)

Friday, April 20, 2012

Page request Object in asp.net

Asp.net worker process can be called as asp.net run time.This will do all the needed things towards web page processing
When asp.net page request comes to asp.net worker process,it will create web page class object and makes a call to process request method.process request method will execute web page by performing following things:
*Initializing memory
*Loading Data and controls[creating server side control objects]
*executing subprograms for button click [Executing post back events]
*It will convert server side control into client side controls[Rendering Html Content to browser]
*Release the memory

Thursday, April 19, 2012

Difference between constructor and destructor in c#

Constructor:
*It is a special type of method  which will be executed automatically while crating an object
*Constructor name must be same as class name with out return type
syntax:
public class_name()
{
}
*These are overlodabale
*These are used to initialize the variables to open files or database connection etc
Destructor:
*It will be executed automatically while destroying object
*The name of destructor  must be same as class name with a ~(tild) prefix and with out return type and  with out access specifiers
syntax:
~class_name()
{
}
*These are not over lodable
*It is used to de-allocate the memory

Tuesday, April 17, 2012

How to use DataReadear in asp.net

Title: What is Data Reader and How to use Data reader

Description:Data reader is Read only and forward only.Simple description for those two properties
Read Only-->Data Reader doesn't support manipulation[insert,delete]
Forward Only-->Data Reader supports Reading records is forwarding direction[Reading only once]

VB.Net:
Dim cms As New OleDbCommand("select*from dept",cn)
Dim dr As OleDBDataReader
dr=cms.ExcuteReader()

C# Syntax:
Before going to use the data reader we should add the name System.Data.SqlClient to our application
SqlDataReader reader =new SqlDataReader();
dr.Read():-It will fetch a record into application process.It returns True fetching record is successfully else false
dr.Item(ColIndex/ColName) or dr(ColIndex/ColName) :-This can be used for any type of data
dr.GetData():-It will produce  better performance
dr.FieldCount:-It returns column count
dr.HasRows:-True:Records are available
                     False:Records are not available
dr.Close:-It will Release memory
dr is a pointer to the temp memory.where the records stored.
Data Reader will fetch record by record and it will consume only one record memory with in  application process.This will reduce burden on application process.Data Reader is strongly recommend when the application requirement is reading data only once with out manipulation

Monday, April 16, 2012

globalization and localization in asp.net

Title: What is Globalization and Localization in asp.net

Description:
Providing content of your application in local is localisation.As assembly is targeted one particular assembly is satellite assembly.The extension of resource file .ress.Creating an .net application with the support for only one local language like Hindi is called as localisation and creating an application with the support of multiple languages is called as globalization

        For implementing localisation or globalization you need to create satellite assemblies.A satellite assembly is an assembly i:e targeted for one particular culture.For different cultures of different countries MS provides different key words.The keyword for US English culture is "EN-US",Keyword for Indian Hindi Culture ""HI-IN" and so on

  To create satellite assembly you need to create a resource file that has the extension .ress and this resource file will be compiled to a DLL file that is targeted for the culture for which resource file is created and this dll is called as satellite assembly

Sunday, April 15, 2012

how to create and use shared assembly in asp.net

Shared Assembly are module level dynamic link libraries,the shared assembly DLL file features we can distribute in all .net technologies.It sharing the features from he assembly folder.This folder located in c:/windows(xp) The shared assembly DLL files having unique version command SN option -K .The command option created one file SNK strong name key ,which is located in DLL.The exe file doesn't communicate directly with DLL

Strong Name Key file:SNK file is the communicator between .net exe file of shared assembly,The strong Name Key file having unique version,this file reference we have to add in the Assembly info.cs file

SN:it is the .net frame work DOS command,using the command we can get unique version from the OS

SN command Options -K:Using this option we can create the key file ,that file maintain the unique version after creating the shard assembly dll file with unique version.Manually we have to install DLL into the Assembly folder

Gacutil command option -i:Using this option we can install the shared assembly dll file into the assemble folder

 -U: Using this option we can uninstall shared assembly DLL file from the Assembly folder Example:
Got to class library project module
namespace classlibrary 1
{
public class class1
{
public string addstr(string s1,string s2)
{
return== s1+s2;
}
}}
Creatiing SNK file :Open vs.net command prompt by clicking start menu,msvs2010,vstools click on command prompt go to dll file location my computer-->d drive-->test-->debug In the VScommandPrompt cd copy the path -->sn -k abc.snk In debug folder created on file "abc".The adding abc.snk file reference in the assembl info .cs file

Assemblyinfo.cs:This file is used to give the information about meta data of dll file.Here we can also give title,description nd version information to dll file Tp open the Assembly info file go to solution explorer,extract properties folder ,double click on the asemblyinfo.cs file *Build the class library project,getting dll file *Installing shared assembly dll file into assembly folder *Adding shared Assembly reference -->click on project menu -->add reference,select browse tab--goto project location--select the dll file ==click on ok
using classlibrary1
button_click
{
class obj1=new class1();
string str;
str=obj.addstr("csharp",".net");
messageBox.show(str);
}

Saturday, April 14, 2012

Dataset serialization and deserialization in asp.net

Serialisation is the process of converting on object into string.Deserialization is the process of creating object from "string".These two process are required in two cases.

1.Persistency object into hard disk memory
 2.Transmitting object a network wire

 Persisting object requires explicit serialisation and deserialization.Transmit object an network wire will perform implicit serialisation and serialisation using distributed technology services Data set supports XML based processes.
Data set is providing fallowing methods to perform things
*Write XML
*Read XML
*Get XML

what is data set in asp.net

Title:How to use data set in asp.net

Description:
The data set is designed to targeting to distributed Technology requirements[Remoting&Web services]

1.Data set acts like In memory database for client application process.this will maintain collection of tables called "Data Tables"
2.Data set supports Bidirectional navigation and manipulation where constraints can be applied
3.Data set is purely disconnected implementation.This provides flexibility for strong multiple tables from different data bases
4.Data set internal storage is XML format.This supports cross platform transmission
5.It can be transmitted across hetero generous platform


Thursday, April 12, 2012

Synchronous and asynchronous connection in asp.net

The application main thread is waiting for response of data base is called :"synchronous connection".In this the main thread is idle[no execution in the application] till database connectivity established. The main thread of application is not waiting for response of data base server is called "Asynchronous connection",In this case main thread will perform execution with in application with out waiting for data base response.It will improve the performance of application Asynchronous connection is recommended when the fallowed statement are not dependent on connection. 1.making connection with other data base 2.Performing remote nethod\3.Displaying form to accept data from user I will give an simple exam for how to implement the asynchronous connection using thread concept In this the asynchronous connection can be implemented to perform parallel implementation of data entry and data base connectivity.
Imports System.Data.Oledb
Imports System.Threading

public class form1

Dim cn As New OleDbConnection("provider=msdaora;user id=scott;password=tiger")
private sub connect()
cn.Open()
MsgBox("connected)
//Form1_load
Dim t As Thread
t=New Thread(address of connect)
t.start()
//save button _click
if cn.State=ConnectionState.Open
Then
Msgbox("wait for some time)
End If
End Sub

how to format an excel cell in asp.net

Is there any properties to make changes dynamically to the cells of excel sheet in asp.net?i would say we can do dynamically any changes.The creation of an excel sheet in asp.net is pretty simple.Here i have used Microsoft Interop dll to create excel.if we want change the width ,text align,color etc of cell ,The below example will show how simple it is.
//column width
 ((Excel.Range)xlWorkSheet.Cells[2, 3]).EntireColumn.ColumnWidth = 45;
//Align center for text
 xlWorkSheet.get_Range("c11", dstrowcount).Columns.HorizontalAlignment = 3;
//merging cells
 xlWorkSheet.get_Range("e2", "j2").Cells.Merge();
//color chage for selected text
 Excel.Range range = xlWorkSheet.get_Range("d5");
 range.get_Characters(1, 5).Font.ColorIndex = 14;
//border color & lines settings
xlWorkSheet.get_Range("c11", dstrowcount).Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
xlWorkSheet.get_Range("c11", dstrowcount).Borders.ColorIndex = 15;
//font setting
((Excel.Range)xlWorkSheet.Cells[8, 4]).Cells.Font.Bold = true;

Tuesday, April 10, 2012

how to display the spelling of a number in asp.net

I have a requirement to display the spelling of the number instead number(0-999) in asp.net.For this i tried so many ways but i did not get the desired result.Finally i will go thorough the simple string array concept which is pretty simple to get the result. Here i will take string arrays which are ones,tens. Based on  the number range i will check the condition and assign the array item to result string
int n=int.parse(txtnumber.Text);
int i=0;
string s="";
string [] ones=new string[]{"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen",fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};

string [] Tens=new string[]{"one","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninty"};

if(n>99&&n<1000)
{
i=n/100;
s=ones[i-1]+"hundred";
n=n%100;
}
if(n>19&&n<1000)
{
i=n/10;
s=s+ten[i-1];
n=n%10;
}
if(n>0&&n<20)
{
s=s+one[n-1];
}
Txtspell.Text=s;

Monday, April 9, 2012

how to read data from excel file in asp.net

Here will how to read the data from excel and export record information to label.For this i will use data reader which id used to read and forward the data .We can not do the manipulations the data while passing from excel to data reader Asp.net:
using System.Data.OLEDB;
//pageload
OleDbConnection cn=new OleDbConnection("provider=microsoft.jet.oledb.4.0;datasource=e:\\asp.net12\\inventorymdb");
OleDb Command cmd=New OleDb Command("select *from product",cn);
OleDbDataReader dr;
cn.Open():
dr=cmd.ExcuteReader();
while(dr.Read)
{
//arrabge record info into label
lblproductinfo.Text=dr["proid"].ToString()+" "+dr["proname"].ToString();
}
vb:
Dim cn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;datasource=e:\asp.net12\inventorymdb")
Dim cmd As New OleDbCommand("select *from product",cn")
Dim dr As New OleDbDataReader
cn.Open()
dr = cmd.ExcuteReader()
While dr.Read
 'arrabge record info into label
 lblproductinfo.Text = dr("proid").ToString() & " " & dr("proname").ToString()
End While

Sunday, April 8, 2012

Different ways of using Data set in Asp.net

Title: Example on Data set in asp.net

Description:As in previous article we just have learnt the basic and theoretical concept of data set .Now i would like to explain the different ways data set usages .Data set is Independent component with in Ado.net.It can be build in three ways
1.manual approach
Dataset ds=New Dataset();
DataTable dt=New DataTable("Orders");
dt.Columns.Add("orderno",type(int);
ds.Tables.Add(dt);
2.Using Data Adapter
SqlDataAdapter da=New SqlDataAdaper("select *from Orders",con);
Dataset ds=New Dataset();
da.fill(ds,"orders");
fill method will perform 3 ways.It will establish connection,send select statement to data base and will close the connections
3.using XML storage
Dataset ds=New Dataset();
da.ReadXML("/Orders.xml");

Wednesday, April 4, 2012

Type casting with c#.net

Recently i have seen one Query about c to c# data type convert.Type concept is a concept of converting one data type to another data type.C#.net supports two types of typecasting. Implicit Typecasting:It will be done under control of CLR and convert from lower to higher ex:
byte x=10;
int i=x;
byte-->int
Explicit Type Casting:It will be done undercontrol of programmer and convert data type from high to lower
int i=10;
byte x=i;
int-->byte
obs:
long-->Int:-Explicit
float-->double:-Implicit
Int-->Float:-implicit
Float-->Int:-Explicit
C#.Net supports 4 types of methodologies for explicit type casting 1.c++ style of casting 2.Converting 3.Parsing

Tuesday, April 3, 2012

Dynamic css styles in asp.net

There are two different ways of applying css styles to asp controls .The customised css are easily control by .net.Here i will explain how to apply the css styles and The javascript functions like on mouseover and on mouse out are apply to hyperlink control dynamically.For this we have an property to add the attributes to server controls i:e "Attributes".
hrss.Attributes["style"] = "background: url(" + imgpath + ") no-repeat scroll 165px center #EEEEEE;display: inline-block;margin-left: 45px;margin-top: 10px;padding: 5px 20px 5px 0;text-align: right;width: 160px; color: #367C2B;";

hrss.Attributes["onmouseover"] = "this.style.color='#BB880B';this.style.background=' url(" + imagpathmouseover + ") no-repeat scroll 165px center #EEEEEE';";

hrss.Attributes["onmouseout"] = "this.style.color='#367C2B';this.style.background=' url(" + imgpath + ") no-repeat scroll 165px center #EEEEEE';";

Monday, April 2, 2012

How to create comma delimited list from table column || Display multiple row data from database into single row

I have two tables which are advertiser and orders.The advertiser table has multiple order's data.so here my requirement is have  to display the order id's list of advertiser with comma delimited in sql.For this i have used XML path elements in sql.
SELECT DISTINCT Advertiser_Id,
(substring( (SELECT ', ' + cast(Order_Id as nvarchar)FROM Dfp_Main_Data e2 WHERE e2.Advertiser_Id = e1.Advertiser_Id group by Order_Id FOR XML path(''), elements),2,500)) as orders ,
o.Notes FROM Dfp_Main_Data e1,Dfp_Orders o  where e1.Order_Id=o.OrderId and e1.Advertiser_Id='"+adverid+"'";

Sunday, April 1, 2012

Allow only numeric or Characters to Textbox

Title:How to allow only Numeric (Numbers) or Characters to Text box in asp.net

Description:
As per previous articles we have seen how to do this kind of functionality using JQuery . Now i would like to explain how to do with asp.net using vb.net.Here an event procedure will be executed before key value is applied to text box.This event procedure allowed developer to kill the functionality of key.
Example:
//keypress event
msgbox("keypresslogic")
msgbox(e.Keychar&" "&Asc(e.Keychar)
If Asc(e,Keychar)=8 Then
Exit sub
EndIf
//To allow numeric
If(char.IsDigit(e.Keychar)=Flase Then
e.Handled=True
MsgBox("enter numeric)
EndIf
EndSub

Bel