Friday, August 30, 2013

DataBinding in windows Forms in asp.net using C#.net

Title:Data binding for windows form using C#

Description:
Data Binding is the concept if providing address of memory location to a control for presenting data.This will reduce coding burden on developer and makes development faster.Below image can give the brief idea on it
Each window for will maintain binding context component.Binding context component will manage currency manager components,Currency manager will maintain record pointer to data-set table,it supports navigation and manipulations,It will place data into Bound Control.
Here the currency manager acts like mediator  between  bound control and memory block

There are two type of data binding con concepts,
1.Simple data binding
2.Complex data binding

Using Simple data binding,control can be bind to only single element.Complex data binding can be bind to more than single element

Tuesday, August 27, 2013

How to use For loop in C#.net

In this articles i will show how to use looping statement in c#.net.In this examples A program to add to textBox at run time. Here i placed one button to perform click event.
code for button click
{
int x=30;
for(int i=1;i<=10;i++)
{TextBox txt=New TextBox();
txt.Text="Txxt"+i;
txt.Location=New Point(100,x);
This.Controls.Add(txt);
x=x+30;
}
In the above code i created 10 text box using for loop condition.The for loop condition takes maximum iteration up to 10 which i was given at condition


Wednesday, August 14, 2013

Datasource Controls in Asp.net


The data source controls are available from asp.net 2.0(Not bound controls).Using this controls we can automate the task of creating data object.Normally we have to prepare data object programatically(using code).Whenever use these controls we may get some question regarding wizard approach features then one programmatic object will be created most importantly these controls provide complete customization options.The following data source controls are available in Asp.net

1.SQL Data source control
2.LINQ Data source control
3.Object Data source control
4.XML Data source control
5.Ado.net entity framework Data source control

1.Sql Data source control:
it is used to prepare data object from any SQL supported database Oracle,SqlServer,Access,My Sql,SYSbase,Informix,Ingres etc


Features:
The DS controls supports caching features . Data source controls does not Cache any data.with enable cache property of it we can add caching support.The reason to cache data is to avoid DB trips for every request.If data is cached then we retrieve data from they cache only by avoiding db.This will improve performance like anything.Different property for caching are also supported for maintaining time ,dependency etc
Conflict Detection(Concurrency control)
Using Data source controls when we manipulate data there is every possibility of occurring concurrency problems because web is for all and also our form can be accessed many users . DS controls provide conflict detection with 2 option

i)Override changes
ii)Compare all values

Wednesday, August 7, 2013

How to create and consume usercontrol without vs.net

Title:How to access user control in asp.net

Description:The use controls can be used when we require a control which can be working as per our requirement.Now i would like to explain how to access this into our web application
1.Use notepad or some other editor and write all aspx/js/html code in it.Save it with .ascx extension
2.Add the created .ascx to the current project i:e copy it into current project folder
3.Go to the page where we want to consume this control and add <%@Register--%> directive
<%@Register Tagprefix="Nit" TagName="RichBanner" src="banner.ascx"%>
4.In the same page now create controls using markup
<Nit:RichBanner ID="rbl" runat="server"/>
5.To Create a control; at run time we cannot use normal syntax for use defined control.We must use load method of page to create it

Ex:-Banner a=page.Load("Banner.ascx")
similarly unload(--) to remove the controls form  form
Remember we must add it to some container after creating it
6.Every control once designed can be placed onto an assembly
7.Only ascx with a dll will be prepared and given to user(publish required)
8.<%@ control--%> directive is used instead of <%@ page--%> and contains will be placed inside a page which contains all HTML content

Tuesday, August 6, 2013

Bind data to Asp.net text box using dropdownlist in jquery

Title: JQuery set text box value in asp.net

Description:
In recent articles we known how to implement the  Data binding concept on data  controls like grid view,Data list,list etc.Here i would like to explain how to bind data to asp.net text box while leave the focus on Drop Down List using JQuery blur function.The blur function will fire when the previous controls has lost focus.

Example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bind data to Asp.net text box using DropDownList in jquery</title>
</head>
<script type="text/javascript" src="~/jquery.min.js" ></script>
<script>
$(document).ready(function() {
$("#ddlSalesOrder").blur(function(){
var SalesOrderText = $("#ddlSalesOrder option:selected").text();
 alert(SalesOrderText);
$("#<%= txtOrderTotalAmt.ClientID %>".val(SalesOrderText); 
});
});
</script>
</head>
<body>
Amount: <asp:DropDownList ID="ddlSalesOrder" runat="server">
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>125</asp:ListItem>
<asp:ListItem>150</asp:ListItem>
<asp:ListItem>175</asp:ListItem>
<asp:ListItem>200</asp:ListItem>
</asp:DropDownList>
TotalAmount:<asp:TextBox ID="txtOrderTotalAmt" runat="server"></asp:TextBox>
</body>
</html>
As you can see there is alert to confirmation for drop down selected value will come when the blur event occurs.Whenever we are using JQuery ,we should add JQuery library reference to our application.
In the above example we have taken one drop down list and text box to display the amount order .When the amount Drop down list has lost the focus ,the total Amount will be populate automatically.

Bel