C# : Tutorial of Asp.net with c# and example

Example and code about windows application, web application, SQL, C#, WPF etc which is helpful to developer and programer.

Search This Blog

Asp.Net: How to make Button make as default button in asp.net?

♠ Posted by uvesh in
How to make button as default button?   Your Button put in panel and give button id in DefaultButton property of panel. most of people think and find Button's property to make it default but actually here asp panel is require and set panel's property DefaultButtton="Here write button id which you want to make default"  . <asp:Panel ID="pnl1" runat="server" DefaultButton ="Button1">   <asp:Button ID="Button1" runat="server" text="Click Me!" />    <asp:Button ID="Button2" runat="server" text="PushMe" /> </asp:Panel> Here ...

SQL: 'IN' Query example in SQL with c#

♠ Posted by uvesh in
Example of 'in Query' in SQL Server Management studio 2008 with C# Whenever you fire where condition in SQL you need give some value in where condition some time you need to only assign only single value or some times you need to assign number of value in where condition that time IN Query is most useful.  there may be in database comma sepreted  value in single field and you need to right in Where condition that time IN Query is most useful to you. For Example In below code First make one string using foreach loop from datatable which is comma sepreted and ten last statement contain SQL Query which contain Where condition.  here Where condition on empid field which compare number of empid at a time which is comma sepreted. string var = ""; foreach (DataRow row in table.Rows) { var += row["emp_no"].ToString() + ","; } if (var.EndsWith(",")) { var = var.Trim().Substring(0, var.Trim().Length - 1); //do sql connection string value1 = sql.GetSingleValue("select...

ASP.Net: How to use ajax calender extender control with demo code in C#

♠ Posted by uvesh in
ASP.NET AJAX Calender Extender use for the get selected date in particular control like textbox,Image button or button. Step 1: First of all you need download ajax control toolkit from http://ajaxcontroltoolkit.codeplex.com/ and add in your project Bin Folder by right click on Bin  Folder And select add reference. then add following code in web.config file of asp.net project or website: <pages>       <controls>                 <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions,...

how to use ispostback proerty in asp.net with example

♠ Posted by uvesh in
Use of IsPostBack property and its example It is not method. It is the property in the System.Web.UI namespace. It should be Page.IsPostBack. IsPostback property is used to Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback. This IsPostBack property returns the boolean value either True or False. The following example shows how to test the value of the IsPostBack property when the page is loaded in order to determine whether the page is being rendered for the first time or is responding to a postback. If the page is being rendered for the first time, the code calls the  excuteonpageload() method. private void Page_Load() {     if (!IsPostBack)     {         // Validate initially to force asterisks         // to appear before the first roundtrip.         excuteonpageload();     } } After render the...

use of Gridview control in asp.net and example of gridview

♠ Posted by uvesh in
What is gridview conntrol in asp.net and its use ? gridview is a very useful control in asp.net.  gridview is mainly uses for display data in tabularform. it also can edit, update, insert data.  this can help you to display and format tabular data very easy and fastest way.  we can format the gridview's nearly all parts as example header, row, alternate row, paging etc.  even we can place insert,edit,delete button for each row.  Example of Grid view control using .aspx page in asp.net as follow: In this simple example we create a default formatted gridview. we also create a sqldatasource control populate the data source by a simple database query. <script runat="server">      </script>      <body>       <form id="form1" runat="server">       <div>                  <asp:GridView...

List of event in page life cycle of asp.net

♠ Posted by uvesh in
Page life cycle of asp.net A list of events in the ASP.NET page life cycle. 1. PreInit: Check for the IsPostBack property to determine whether this is the first time the page is being processed. Create dynamic controls. or reCreate dynamic controls. Set master page dynamically. Set the Theme property dynamically. Read profile property values. Set profile property values. If Request is postback: The values of the controls have not yet been restored from view state. If you set control property at this stage, its value might be overwritten in the next event. 2. Init: In the Init event of the individual controls occurs first, later the Init event of the Page takes place. This event is used to initialize control properties. 3. InitComplete: Tracking of the ViewState is turned on in this event. Any changes made to the ViewState in this event are persisted even after the next postback. PreLoad: This event processes the postback data that is included with the request. 4....

Concept of MVC (Model View Controller) in asp.net

♠ Posted by uvesh in
Definition of MVC(Model View Controller) in asp.net MVC is one of three ASP.NET programming models. MVC is a framework for building web applications using a MVC (Model View Controller) design: The Model represents the application core (for instance a list of database records). ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast. Models-: Model objects are the parts of the application that implement the logic for the applications data domain. Often, model objects retrieve and store model state in a database. Such as a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in SQL Server. In small applications, the model is often a conceptual separation instead of a physical one. For example, if...

C# : Insert data in sql database using stored Procedure in asp.net

♠ Posted by uvesh in ,
How to insert data in sql server database using asp.net and c# First of all require to Create database, create connection, and then Following code help full to you string constring = "Data Source=server name here.;Initial Catalog=DatabaseName;Integrated Security=True"; SqlConnection dbCon = new SqlConnection(constring); SqlCommand sqlCmd; DataTable dbTbl; sqlCmd = new SqlCommand(); dbCon.Open(); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Connection = constring; sqlCmd.CommandText = ("INSERT INTO TABLE NAME VALUES(jack,newyork,U.S.A) "); sqlCmd.ExecuteNonQuery() dbCon.Close(); Example of Above code string constring = "Data Source=localhost.;Initial Catalog=Shop;Integrated Security=True"; SqlConnection dbCon = new SqlConnection(constring); SqlCommand sqlCmd; DataTable dbTbl; sqlCmd = new SqlCommand(); dbCon.Open(); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Connection = constring; sqlCmd.CommandText = ("INSERT INTO EMP ...

Asp.Net TextBox Control example with its main property

Example of Basic Textbox and its property in asp.net The TextBox control is used to create a text box where the user can input text or symbol. A basic TextBox as follow: <asp:TextBox id="textbox1" runat="server" /> <br /><br /> A basic TextBox:  A password TextBox as follow: <asp:TextBox id="textbox2" TextMode="password" runat="server" /> <br /><br /> A password TextBox:  A TextBox with text as follow: <asp:TextBox id="textbox3" Text="Hello World!" runat="server" /> <br /><br /> A TextBox with text:  A multiline TextBox as follow: <asp:TextBox id="textbox4" TextMode="multiline" runat="server" /> <br /><br /> A TextBox with height as follow: <asp:TextBox id="textbox5" rows="4" TextMode="multiline" runat="server" /> <br /><br /> A multiline TextBox:  A TextBox with width as follow: <asp:TextBox id="textbox6" columns="20" runat="server"...

How do i bind data in asp.net textbox control run time and design time and some important property of textbox

♠ Posted by uvesh in ,
Bind data in text box in code behind and in aspx means design time Bind data in text box at design time as follow: <asp:TextBox id="textbox1" Text="Hello World!" runat="server" /> its display: Hello World! Bind data in text box at codeing  time or in code behind page as follow: textbox1.text = "Hello World!" it display as :"Hello World!" Bind data in text box at codeing from database or data source as follow: textbox1.text = datarow["field name of datatable or database"]; Example : textbox1.text = datarow["firstname"]; Important Property of Asp.Net Textbox control as follow: AccessKey:specify a key that navigates to the TextBox control.             Example :   <asp:Textbox ID="txt" runat="server" AccessKey="T"  Text="<u>T</u>ext Here:"> </asp:Textbox> here click on Alt+T you can access this textbox. AutoCompleteType: associate...

Data bind in asp.net using Listview control instead of eval method

♠ Posted by uvesh in ,
Use and Importance of List View Control  Data Binding in aps.net without Eval Bind method The use of the Eval and Bind methods can be complicated. This method with Data-Binding Expressions are GridView,, Repeater, and ListView. These are actually Data-Bound controls which can be bound to Data Source controls such as SqlDataSource. Here ways to reduce the complexity of usage of the Eval method. example of Without eval. If you are using eval method to bind data for large web applications with millions of clicks per minute, the Eval method isn’t really the perfect solution. There is everything hard-coded in HTML. In this example, we are not going to use the Eval or Bind methods, nor are we are going to use Data Source controls. We are going to do everything from the server side. ListView : This control has some very important event that we are going to heavily manipulate - ItemDataBound. It has templates, e.g., ItemTemplate and EditItemTemplate. Our example...

How to bind data in checkboxlist control of asp.net? and property of checkboxlist control

♠ Posted by uvesh in ,
Checkboxlist: Creates a multi selection check box group that can be dynamically created by binding the control to a data source. Data bind in CheckBoxList in asp.net following code for aspx page  <asp:CheckBoxList ID="CheckBoxList1" runat="server"    DataSourceID="SqlDataSource1" DataTextField="text" DataValueField="text">   </asp:CheckBoxList> Data Bind in CheckBoxList in asp.net following Code write in Code behind page if (!IsPostback) { CheckBoxList1.DataSource = dataset/datatable/datasource; CheckBoxList1.DataTextField = "tex"; CheckBoxList1.DataValueField = "text"; CheckBoxList1.DataBind(); } Use Full Property pf asp ListBox control as follow: AppendDataBoundItems, AutoPostBack, CausesValidation, DataTextField, DataTextFormatString, DataValueField, Items, runat, SelectedIndex, SelectedItem, SelectedValue, TagKey, Text, ValidationGroup, OnSelectedIndexChanged Improve Your Answer as comment below. If our...

C#: How to bind radio buttonlist in asp other control like checkboxlist,listbox,dropdownlist

♠ Posted by uvesh in
asp.net controls which support data binding: asp:CheckBoxList asp:RadioButtonList asp:Listbox asp:DropDownList The selectable items in each of the above controls are usually defined by one or more asp:ListItem controls <html> <body> <form runat="server"> <asp:RadioButtonList id="countrylist" runat="server"> <asp:ListItem value="S" text="Sunday" /> <asp:ListItem value="M" text="Monday " /> <asp:ListItem value="T" text="Tuesday " /> <asp:ListItem value="W" text="Wednesday" /> <asp:ListItem value="Th" text="Thersday" /> <asp:ListItem value="F" text="Friday " /> <asp:ListItem value="S" text="Saturday " /> </asp:RadioButtonList> </form> </body> </html> Improve Your Answer as comment below. If our post is useful please share and comment on our post for more post and detail Visit : http://aspdotnethelpmaster.blogspot.in/ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ ...

Asp.net : What is ListView in asp.net and how it is use for binding Data?

♠ Posted by uvesh in
Definition of ListView and use of List view ASP.NET have a new data binding control named the ListView. ASP.NET already has a number of  data bind controls. It may be more then 10 databinding control. ListView literally replace all other data binding controls in ASP.NET.  ListView Control easy very easy for databinding. ListView control makes data binding easier than previous controls. It has default included styling with CSS, more flexible paging, and sorting, inserting, deleting, and updating features and many more. The ASP.NET ListView control enables us to bind to data items that are returned from a data source and present  them to end user. You can display data in pages so there is also load balancing at end user even there is large amount of data because of paging user no need wait for load data. You can display items individually, or you can group them. The ListView control displays data in a format that you define by using templates and styles. It...

C# : comment in asp.net or c sharp and use of it and short cut key for do comment

♠ Posted by uvesh in ,
How to comment code in asp.net? Comment code in asp.net page as follow: <%write comment here%> Shortcut key for do comment in aspx page in asp.net as follow: CTRL + K, CTRL + C For Make comment selected text. CTRL + K,CTRL + U For Remove  comment of selected text. Do comment in aspx.cs(code behind) page in asp.net as follow: //comment  can write here advantage of comment or use of comment as follow: Removed at compile-time Doesn't increase size of markup You can even optimize with them Improve Your Answer as comment below. If our post is useful please share and comment on our post for more post and detail Visit : http://aspdotnethelpmaster.blogspot.in/ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ...

C#: how to bind data in repeater control in asp.net? and example of repeater with c# code

What is Repeater Control? Repeater Control is a control of asp.net which is used to display the data which is daynamic and repeatedly change collection of record How to work repeater control of asp.net? The Repeater control works by looping through the records in your data source and then repeating the rendering of it’s templates called item template. Repeater control contains different types of template fields those are 1) itemTemplate 2) AlternatingitemTemplate 3) HeaderTemplate 4) FooterTemplate 5) SeperatorTemplate what is use of ItemTemplate in repeater control of asp.net? ItemTemplate defines how the each item is rendered from dataBase collection. what is use of AlternatingItemTemplate in repeater control of asp.net? AlternatingItemTemplates is used to change the background color and styles of AlternatingItems in DataBase collection what is use of HeaderTemplate in repeater control of asp.net? HeaderTemplate is used to display Header text for DataSource...

Asp.Net Master Page Tutorial

♠ Posted by uvesh in ,
What Is Master Page in Asp.Net and How To create master page in Asp.Net What Is Asp.Net master page? In Web site development with Asp.Net, the master page is a feature that enables you to define common structure and interface markup elements for your web Site, including headers, footers, style definitions, or navigation bars. The master page can be shared by any of the pages in your Web site, called the content page, and removes need to duplicate code for shared elements within your Web site. For instance, if you would like to display a standard header and footer in each page of your website, then you can generate the standard header and footer in a Master Page. That’s how powerful a master page is to handle multiple forms and is easier to maintain throughout what the website looks like. Take note, the ID attribute uniquely identifies the placeholder, allowing you to put more than one placeholder in a master page. How to Create Master Page in Asp.Net? To...

User Control:How do i create user define control in asp.net c#

♠ Posted by uvesh in
How use Userdefine Control in Asp.Net For create asp.net user define control using c# following step perform Definition of UserControl in Asp.Net : In Asp.Net Web server controls , you can create your own custom, reusable controls using following step. These controls are called user controls. A user control is a kind of composite control that works much like an ASP.NET other server control . you can add existing Web server controls and markup to a user control, and define properties and methods for the control. You can then embed them in ASP.NET Web pages like same as other server...

SQL Connection: Very Easy Code For SQL Connection by C# and Asp.Net

♠ Posted by uvesh in
How To make sql connection using C# Asp.net The first of all need to do when interacting with a data base is to create a connection. It Microsoft SQL Server is a relational database management system developed by Microsoft. Manages all of the low level logic associated with the specific database protocols. In code is instantiate the connection object, open the connection, and then close the connection when you are done. Because of the way that other classes in ADO.NET are built, sometimes you don't even have to do that much work. Although working with connections is very easy, you need...

Features of c# or advantage of c#

By This Article We Explain Features of C#  Modern Object oriented Type safe Version able consistent compatible flexible 1.    Modern : It supports, Automatic garbage collection, modern approach to debugging, rich intrinsic model for error handling, decimal data type for financial. Object :  It supports object-oriented system, namely Encapsulation, Inheritance and Polymorphism. Type-Safe :                                                                i.      Type...