aspx Tutorial

NET Articles,jQuery demo, with jQuery, online tutorial,Jquery, SilverLight, Javascript,,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here


Get our toolbar!


by Aamir Hasan   on Tuesday, December 21, 2010
The following example demonstrates how can we count the number of rows in a table using jQuery.. More
by Aamir Hasan   on Monday, December 13, 2010
how to load web user control dynamically in your ASP.NET web form More
by Aamir Hasan   on Monday, December 6, 2010
Yesterday developer asked me, distinct method on a column using linq is not woking. So, i have decided to wite this example in my blog to share with all of you. Let’s startOpen your Visual Studio 2008/2010 from File -> New -> New Web Site. Following is the code of Default.aspx page.<html xmlns=""><head runat="server">    <title></title></head><body>    <form id="form1" runat="server">    <div>        <asp:GridView ID="GridView1" runat="server">        </asp:GridView>    </div>    </form></body></html>Following is the code of Default.aspx.cs page. protected void Page_Load(object sender, EventArgs e)    {        GridView1.DataSource = from i in getAllEmployee()                               group i by i.FullName into temp1                               select temp1.Key;        GridView1.DataBind();    }    public List<Employee> getAllEmployee()    {        List<Employee> emp = new List<Employee>()        {            new Employee(){ ID=1, FullName="Aamir Hasan", Age=25 },            new Employee(){ ID=2, FullName="Awais Ahmed", Age=21 },            new Employee(){ ID=3, FullName="Saba khan", Age=11 },            new Employee(){ ID=4, FullName="Mahwish Hasan", Age=18 },            new Employee(){ ID=5, FullName="Hina", Age=26 },            new Employee(){ ID=6, FullName="John", Age=24 },            new Employee(){ ID=7, FullName="Aamir Hasan", Age=22 },            new Employee(){ ID=8, FullName="Awais Ahmed", Age=21 },            new Employee(){ ID=9, FullName="Aamir Hasan", Age=20 },          };        return emp;    }    public class Employee    {        public int ID { get; set; }        public String FullName { get; set; }        public int Age { get; set; }    } Note: You can get distinct values of any column by using above  linq query syntax. Output Download (1.11 kb) See live demo
by Aamir Hasan   on Sunday, December 5, 2010
how to clear all char from current StringBuilder class instance More
by Aamir Hasan   on Wednesday, November 24, 2010
How to display row number in gridview... More
by Aamir Hasan   on Saturday, November 20, 2010
Serval times this question has been asked from me that how to create linq to SQL connection in So, i have decided to write this example here.In this example, I have used northwind database. First, I have created a connection string and establish a connection between object to database, then select [categoryname] from [categories] table.Finally, through loop i have display the category names on the page.Here’s the solution        string connectionString = "Data Source=.;Initial Catalog=Northwind;Integrated Security=True";        using (SqlConnection connection = new SqlConnection(connectionString))        {            using (NorthwindDataContext context = new NorthwindDataContext(connectionString))            {                var query = from c in context.Categories                            select c.CategoryName;                foreach (var title in query)                {                    Response.Write(title);                }            }        }
by Aamir Hasan   on Thursday, November 18, 2010
How to embed flash banner in your page More
by Aamir Hasan   on Wednesday, November 17, 2010
Session variables are stored at server side, by default Session timeout will expire after 20 minutes. We can change the ASP.NET Session timeout in Web.Config and code behind. In this example, i have changed the ASP.NET Session timeout value to 1 hour in the Web.Config Here’s is the solution<configuration>  <system.web>    <sessionState      timeout="60" />  </system.web></configuration>Note: If you have increase ASP.NET Session timeout then you have to increase application idle timeout from Application pool, if Session timeout is greater then Application pool idle timeout then Session will be expire because Application is recycled before session timeout.
by Aamir Hasan   on Thursday, November 4, 2010
Yesterday, some one asked me how to remove whitespaces at beginging and end of a string in javascript. So, i decided to make a trim function which will remove whitespaces from begining and end of a string. Here's an example <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""><html xmlns=""><head runat="server">    <title></title>    <script language="javascript">        function LTrim(value) {            var re = /\s*((\S+\s*)*)/;            return value.replace(re, "$1");        }        function RTrim(value) {            var re = /((\s*\S+)*)\s*/;            return value.replace(re, "$1");        }        function trim(value) {            return LTrim(RTrim(value));        }        function getValue() {            var username = trim(document.getElementById('<%=TextBox1.ClientID %>').value);            if (username != '')                alert(username);        }          </script></head><body>    <form id="form1" runat="server">    <div>        Username:        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        <input id="Button2" type="button" value="Submit" onclick="return getValue();" />    </div>    </form></body></html> Output Download Trim (894.00 bytes) Live demo
by Aamir Hasan   on Thursday, September 16, 2010
There are few JQuery Plugin’s on the internet, one on them is column/row hover jQuery Plug-in.I am going to demonstrate how to use column hover Plug-in with ASP.NET to display student information by fetching JSON data from server side to client side.When you take your mouse over the table column, column will be highlighted. This example uses the JQuery library. I have made this example in Visual studio 2010.when you create a web project in Visual Studio 2010, jQuery include in web project. If you don’t have Visual Studio 2010 then you can download JQuery latest version from here. Let start's. Open you Visual Studio 2010. Create a new Web Application. Open you Default.aspx Page. Add the following code given below. [WebMethod] public static List fetchStudentRecords() { List AddRecords = new List(); AddRecords.Add(new Student { RollNumber = 1, FullName = "Aamir Hasan", Class = "Five", Marks = 94, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 2, FullName = "Scott Hanselman ", Class = "Four", Marks = 93, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 3, FullName = "Saba Khan", Class = "Three", Marks = 82, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 4, FullName = "Nadia yasir", Class = "Nine", Marks = 80, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 5, FullName = "Mahwish Hasan", Class = "Two", Marks = 79, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 6, FullName = "Aamir Hassan", Class = "One", Marks = 99, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 7, FullName = "Karoly Domonyi", Class = "Five", Marks = 69, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 8, FullName = "Sana Ahmed", Class = "Five", Marks = 93, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 9, FullName = "Awais Ahmed", Class = "Ten", Marks = 91, Gender = "Male" }); return AddRecords; } } public class Student { public int RollNumber { get; set; } public String FullName { get; set; } public int Marks { get; set; } public string Class { get; set; } public string Gender { get; set; } } Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Note: Add System.Web.Services at the top of page to work web Method   Open your Default.aspx Page add css reference under head tag, for table style. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <link href="Styles/Style.css" rel="stylesheet" type="text/css" />   Add jQuery and table hover reference under head tag. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="Scripts/jquery.tablehover.js" type="text/javascript"></script>   Add the following code to retrieve JSON object using $.ajax method. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <script type="text/javascript">         $(document).ready(function () {             $.ajax({                 type: "POST",                 url: "Default.aspx/fetchStudentRecords",                 data: "{}",                 contentType: "application/json; charset=utf-8",                 dataType: "json",                 success: function (data) {                       $("#records").html(GenerateTable(data.d));                     $('#table1').tableHover({ colClass: 'hover' });                 }             });             function GenerateTable(data) {                 var totalRows = data.length;                 var Table = "<table id='table1'>";                 Table += "<thead><tr><th>Roll No.</th><th>Full Name</th><th>Marks</th><th>Class</th><th>Gender</th></tr></thead><tbody>";                 for (index = 0; index < totalRows; index++) {                     Table += "<tr ><td>" + data[index].RollNumber + "</td><td >" + data[index].FullName + "</td><td>" + data[index].Marks + "</td><td>" + data[index].Class + "</td><td>" + data[index].Gender + "</td></tr>";                 }                 Table += "</tbody></table>";                 return Table;               }           });     </script>   Above you see, on page load, returning Date objects in the form of JSON Serialized List<Student>. Table is generated when JSON data is returned. Add following code under the body section. <h2>Table Hover jQuery plugin with using csharp</h2> <div id="records">&nbsp;</div> Press Cltr+F5 to save and run your web application. Below you can see output you can download entire source code from here. Click here to see online demo.
Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5