Showing posts with label Asp.net Basics. Show all posts
Showing posts with label Asp.net Basics. Show all posts

Monday, July 29, 2013

Bind data to Asp.net text box using jquery

Title: JQuery bind data to asp.net text box using Blur function

Description:
As per previous articles we have gone through different kind of data binding examples using jquery in asp.net.Now here we will learn about the usage of jquery functionality for web control.

Example:
Now i would like give an example to set the data to Text box in asp.net using jquery.This application will use to  set the food orders.As per requirement we need to assign the value to text box control based on food category Id.To accomplish this task  i have utilized  Jquery script function i:e Blur() which make the functionality what ever we used inside of it

$(document).ready(function() {
$("#<%= txtOrderList.ClientID %>").blur(function(){
var orderList = $(this).val();
$("#<%= txtOrderList1.ClientID %>".val(orderList); 
});

The above script will will bind the data to text box when the other text box focus has moved.You can use this functionality as per requirement very quickly.
This article may help you a lot..Keep visit my website

Wednesday, July 24, 2013

Creating Database WithOut GUI in asp.net

Title:Create new data base using dot net framework 

1.With in object explorer right click on the database note and choose new database to open new database dialog box
2.In that new database dialog box at the database name option provide a name to the database and keep the owner as the default
3.By default one data filer and one log file are created automatically and will be shown in as table when you ant to create additional files and log files.
4.Click on add button at the bottom of the table.The table provides the first column name that can be used to specify logical name of the file .
5.File type column to specify whether the data file belongs to primary or secondary file group and the initial size column to specify initial memory to be allocated to the file
6.Use the auto growth column to specify how much memory to be incremented to the file.When it names additional memory and the maximum limit for the file.
7.To change these option click on the button on right side of the column .Auto growth that open a dialog box with in they dialog box specify the file growth and max size and click on OK button
8.Use  the column path to specify the physical path where you want to save the file to change the path ,click on the button on right side of the column path
9.After specifying the all the files required for the data base click o OK button to complete the Creation of database and click the dialog box


Tuesday, July 23, 2013

Serverside programming in Asp.net

1.All programs that are written as html/Js are executed in client system only.
2.The role of server for these programs is simply send a copy of program to client browser and its JS independent exceeds the code in client
3.Now when we write server side programs the program will be executed at server only .
4.The result will be sent back to client .All client side ans server side programs are based on execution only.
5.In web application extension are very important.
6.Many server side  environment are provided to develop server side scripting and web application

Friday, July 19, 2013

Components of .net framework

Many of the updated and code related things have discussed on er-liar. In this post i just give some basic Concepts of .net framework.
The components of .net frame work:

1.Common Language Run time(CLR)
2.Base class library
3.Framework Class Library

Components of CLR:
1.Common language specification(CLS)
2.common type system(CTS)
3.garbage collector
4.Just in time

Thursday, July 18, 2013

Bind data to RadioButtonList with arraylist in asp.net

Title:
How to bind data to web server control using array list in asp.net using c#

Description:
Array list can hold list of items of similar data type.When  we want  declare the array list with specific size,no need to set the size of array list,because it can be re sizable automatically .

Example:
The below example will show how to add data statically and dynamically to radio button through array list.But  the binding concepts are also utilize for bind data to this standard control..Later articles i would like give all methods regarding array list

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ArrayList listNum = new ArrayList();
listNum.Add("b");
listNum.Add("h");
listNum.Add("a");
listNum.Add("k");
listNum.Add("r");
rbNumber.DataSource = listNum;
rbNumber.DataBind();
}
}
I hope it is helping for you.Thanks for coming and visit again

Wednesday, July 10, 2013

New features in Asp.net MVC 5

Erliar i have given Asp.net MVC4 related information with examples. Now the new version has came which is MVC 5 with new features.The below link will give the complete tutorial of MVC 5 with examples

Wednesday, June 19, 2013

page error event in asp.net

This event can have error handling code using which user can get some info about the problem.Normally we will create page error event code by redirecting user with that page
protected void page_error(object seender,EventArgs e)
{
Response.Redirect("Error. Html");
}
protected void btn_clikc(object sender,EventArgs e)
{
int a=0,c=10;
int b=c/a;
Response.Write(b.Tostring());
}
Implemented using <custom errors> tag of web.config and also using application _error event of Global.aspx  file
Web.config:
<custom errors mode="on" DefaultRedirect="error.html"></custom errors>
In the same custom error a sub tag called error is present.In this tag we can specify particular error and redirecting
<appsettings>
<connectionStrings/>
<system.web>
<custom errors mode="ReadOnly" default Redirect="error.html"?
<error status code=404" redirect="nofile.html"/>
If user attempts to go for a file which is not present then nofile page will be displayed and for any other if goes to error page.Here we should notice "both files are created by user"

Friday, April 26, 2013

Asp.net validation controls

Title:How to use validation control in asp.net

Description:
Normally in web application, validation are perform using java script. We must write JS and perform validations.If validations are successful then we redirect the user to sever and if validation fails then we display error to user to perform all these with java script. It is complex and also time consuming.In previous articles i explained how to pass server side variable to client side in asp.net,Validate drop down list in java script,How to validate text box in JQuery

Asp.net developers are provided with validation controls which enable user to perform validation just like server side controls.These validation controls render Jquery to the client or browser like this we can have rapid application development for validation and also we can reduce the Complexity of writing java script code validation controls of asp.net target clients as automatic which means based on browser validation are perform

The fallowing validation controls are supported by asp.net
1.Required Field validator
2.Range validator
3.Compare validator
4.Regular expression validator
5.Custom validator
6.Dynamic validator
7.validation summary

The most common property for validation controls:
Controltovalidate:web control id
Error message =message
setFoucsError=true/false
validation Group :makes the control part of separate validation group
Display:static(default)/dynamic/none
i.static :Initially place for displaying error will be reserved.When error occurs it will be visible otherwise it will be hidden
ii.Dynamic:No place in the form will be reserved initially only on error dynamically the message will be shown
iii.none:will not display the error message only

Required field validator:

Used to check null values and it is the only control that checks null values .Remaining validation controls doesn't perform any validation if null values are entered.IN the below example have used this validation for Textbox(txtOrder) which is used to give the Order value.
<asp:requiredfieldvalidator controltovalidate="txtOrder" display="dynamic" errormessage="Enter Order Details" id="RfOrder" runat="server">* 
</asp:requiredfieldvalidator>

Range validator:

To check for range of values.Useful for numeric and date format of data Additional properties Minimum value :1
maximum Value :1000

<asp:textbox id=" runat="server" txtage=""> <asp:RangeValidator id="RvAge" runat="server" ControlToValidate="txtage" 
 MaximumValue="16" 
 MinimumValue="24" 
 Type="Integer" 
 ErrorMessage="Enter valid age" Display="Dynamic">*</asp:RangeValidator>
Can one control have multiple validation controls? the answers is yes
we can use one validation control validate single controls only

Compare validator:

With compare validation we can perform 3 types of validation all will be based on comparison
1.Control with another control
2.control with value
3.control with data type

 UserName<asp:textbox id="txtuser1" runat="server"/>
 Reenter UserName: <asp:textbox id="txtuser2" runat="server"/>

<asp:CompareValidator ControlToValidate="txtuser1" ControlToCompare="txtuser2" Operator="Equals" ErrorMessage="Please enter valid user name" Display="dynamic">*</asp:CompareValidator>

validation summary control:

Used to report errors as a summary i:e display all control errors.error message display throw summary control.It has two properties
i)show summary :true/false
ii)show messageBox =true/false
when display is set to none then validation control will not display error in its place instead if displays error in summary control .

Regular expression validator:

Using they control we can specify on expression and ask validator to match the expression with control.Previously i have given to validate email using regular expression in asp.net.

Custom validator:

In previous post i have given example on how to use custom validator in asp.net.For complete details click here

Wednesday, January 9, 2013

Disable dropdown list using radio button in asp.net using c#.net

In previous post we have seen how to disable the drop down list using other dropdown list.In the below we will use radio button to disable the drop down list in asp.net using c#.net.For this we have to use radiobutton checked change event
Code behind:
protected void rbcheck_CheckedChanged(object sender, EventArgs e)
{
ddltest.Enabled = false;
}

Aspx:
 <asp:RadioButton ID="rbcheck" runat="server"
 oncheckedchanged="rbcheck_CheckedChanged"  AutoPostBack="true"/>
<asp:DropDownList ID="ddltest" runat="server"
 AutoPostBack="True">
<asp:ListItem>Please select</asp:ListItem>
</asp:DropDownList>

Tuesday, December 11, 2012

what is satellite assembly in asp.net


Assembly which contains only resources information is called as satellite assembly or "Resource only Assembly"
.net is providing Assembly linker utility (al.exe) to produced sattelite assembly

e:\vb.net al/embedresources my resources.resources/out:rassembly.dll
e:\vbnet92>dir r*.dll

It will produce raseembly.dll,this dll contains resources information.

Sattelite assembly exapmle

Wednesday, November 28, 2012

String to DataTable in asp.net using C#.Net

Title:How to bind data table using string array in asp.net using c#

Description:
We have already learnt data binding to data source controls.Now i would like to show how would we use the array list to bind the data to grid view etc.

Examples:
Some  examples for JQuery Auto complete text boxhow to bind or Export CSV data to data table in asp.net.The below example describes the logic of iteration of array list to  data table.In the below i have used a string array to hold the string data and a grid view to display the resultant data of Data table.
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:GridView ID="GvOrdr" runat="server"></asp:GridView>
</asp:Content>

DataTable dtOrdrName = new DataTable();
dtOrdrName.Columns.Add(new DataColumn("Name", typeof(string)));
string[] strSplitOp = new string[] { "bhaskar", "Siva", "Ram" };
for (int i = 0; i <= strSplitOp.Length - 1; i++)
{
DataRow NewDrow = dtOrdrName.NewRow();
NewDrow["Name"] = strSplitOp[i].ToString();
dtOrdrName.Rows.Add(NewDrow);
}
GvOrdr.DataSource = dtOrdrName;
GvOrdr.DataBind();

Saturday, November 24, 2012

UniqueId and ClientID in asp.net

Here i have given two scenarios to explain those importance in asp.net
In case of a control which is placed in a web form without Master Page:
The Id and Name attribute rendered to the browser are same as Id of control on server and thus the same Id/Name can be used

for programming a control in java script

In case of a control which is placed in a web form with Master Page:

The control Client side Id="<%=ServerofControl.ClientID%>" example:ct100_ContentPlaceHolderId_ServerIdofControl

The control Client side Name="<%=ServerofControl.UniqueID%>" example:ct100$ContentPlaceHolderId$ServerIdofControl

1.Add a text box and HTML button to webform/content page which has been page
<asp:TextBox runat="server" ID="txtwform"/>

<input type="button" value="cbutton" onclick="Show()"/>

2.Add the following to the web form (cphHead isId of ContentPaveHolder added to Head Section of Master Page)
<asp:Content ID="chead" ContentPlaceHolderID="cphead" runat="server">

<script>
function Show()
{
var test=document.<%=Page.Form.ame%>.<%=txtwform.UniqueID%>;
alert(test.value);
}
</scrip>

Monday, August 20, 2012

Java script validation on Server side in asp.net

Title:Java script validation in asp.net

Description :
As per previous articles,we discussed on java script validation on client side in asp.net .Now i would like give an example on validation which can be done on server side.In the below example i have used a web server control (Text box size) which should contain 30 characters with specified text format
Example:

if (TxtFormate.Text == "")
{
ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Enter Format');</script>");
TxtFormate.Focus();
return;
}
if (int.Parse(TxtFormate.Text.Length.ToString()) > 30)
{
ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('Allows only 0 to 30 Characters');</script>");
TxtFormate.Focus();
return;
}

Bel