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

Asp.Net Web Forms

Web Forms

It is one of the Three different programming models you can use to create ASP.NET web applications, the others being ASP.NET MVC and ASP.NET Web Pages. ASP.NET Web Forms is a part of the ASP.NET web application framework.
Web Forms are pages that your users request through their browser and that form the user interface (UI) that give your web applications their look and feel. Web form is a combination of HTML, server controls, and server code. When users request a page, it is compiled and executed on the server, and then it generates the HTML markup that the browser can render.

Description 

In previous posts I explained  Value and Reference Types, Asp.net View State, What is the Dataset in ASP.NET,  Difference between .NET Framework 4.5 and .NET Framework 4.0Basics of ASP.NET Now I will explain how to Create Web Form in asp.net using c# .

Step 1 :- 

Open Visual studio

Step 2:-

web-form-in-asp.net

Click on FileàNewàwebsite

Step 3:- 

Browse your Folder where you want to save the Project .

Step 4:-

In  ‘Installed  Templates’ (Left side) select your desired language and finally click on ‘ASP.NET Empty Website’
web-form


Step 5:-

Click on ‘Solution Explorer’ (right side)

Step 6:-

Right click on the   Project path and Click on ‘Add New Item’

Step 7:-

In  ‘Installed  Templates’ (Left side) select your desired language, and click to ‘Add’ button

web-forms

Now a Default.aspx  Web Form has been created in your website.


                                                                                                                                                                                                       







Read More

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Invalid postback or callback argument.  Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


For Appropriate Removal Of this Error We Need To Apply [ if (!IsPostBack) ] on the event Where Grid is filled or we can Say that for the Removal of infinite Looping of a method.

or

If You Dont Need to Do All This Lengthy Process you Need to Write  [EnableEventValidation="true"] on .aspx page (ON TOP)


eg-


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridviewbuttoEvent.aspx.cs" Inherits="GridviewbuttoEvent" EnableEventValidation="true" %>
Read More

What is the Dataset in ASP.NET

Introduction: -

Here I will explain what is Dataset and uses of Dataset with example in asp.net using C# .

Description:-

In previous posts I explained What is Cloud Computing , Difference between .NET Framework 4.5 and .NET Framework 4.0, Basics of ASP.NET. Now I will explain what is Dataset and uses of Dataset with example in asp.net using c# .

What Is Dataset?
A dataset (or data set) is a collection of data.
Most commonly a dataset corresponds to the contents of a single database table, or a single statistical data matrix, where each column of the table represents a particular variable, and each row corresponds to a given member of the dataset in question. The dataset lists values for each of the variables, such as height and weight of an object, for each member of the dataset. Each value is known as a datum. The dataset may comprise data for one or more members, corresponding to the number of rows.

The term dataset may also be used more loosely, to refer to the data in a collection of closely related tables, corresponding to a particular experiment or event.


C# Specifications for code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using Arahan;

public partial class testing : System.Web.UI.Page
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
    SqlCommand cmd = new SqlCommand();
    DataFill d = new DataFill();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.fillgrd();
    }
    public void fillgrd()
    {
        DataSet dst = new DataSet();
        DataTable dt = new DataTable("People");
        dt.Columns.Add("id");
        dt.Columns.Add("name");
        dt.Columns.Add("Age");
        dt.Rows.Add("1","Amit Singh","21");
        dt.Rows.Add("2","Amitendra","21");
        dst.Tables.Add(dt);
        DataTable ds = new DataTable("new People");
        ds.Columns.Add("id");
        ds.Columns.Add("name");
        ds.Columns.Add("Age");
        ds.Rows.Add("1", "Amitendra", "21");
        ds.Rows.Add("2", "Amit Singh", "21");

        dst.Tables.Add(ds);

        dst.Tables["people"].Rows[0][0].ToString();
        dst.Tables["new People"].Rows[0][0].ToString();
        GridView1.DataSource = dst.Tables["new People"];
        GridView1.DataBind();
       
    }

}

ASPX Code Using Grid View:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testing.aspx.cs" Inherits="testing" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <table class="style1">
            <tr>
                <td align="center"
                    style="font-family: verdana; font-size: medium; font-weight: normal; font-style: normal; font-variant: normal; text-transform: none; color: #FFFFFF; background-color: #006699">
                    DataSet Entry</td>
            </tr>
            <tr>
                <td align="left"
                    style="font-family: verdana; font-size: small; font-weight: normal; font-style: normal; font-variant: normal; text-transform: none; color: #006699">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
                        CellPadding="3">
                        <FooterStyle BackColor="White" ForeColor="#000066" />
                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                        <RowStyle ForeColor="#000066" />
                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#007DBB" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#00547E" />
                        <Columns>
                        <asp:TemplateField HeaderText="ID">
                        <ItemTemplate><asp:Label ID="lbl_id" runat="server" Text='<%#Eval("id") %>'></asp:Label></ItemTemplate>
                        </asp:TemplateField>    
                        <asp:TemplateField HeaderText="Name">
                        <ItemTemplate>
                        <asp:Label ID="lbl_nme" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
                        </ItemTemplate>
                        </asp:TemplateField>  
                        <asp:TemplateField HeaderText="Age">
                        <ItemTemplate>
                        <asp:Label ID="lbl_age" runat="server" Text='<%#Eval("Age") %>'></asp:Label>
                        </ItemTemplate>
                        </asp:TemplateField>               
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
   
    </div>
    </form>
</body>

</html>


OUTPUT:



Read More

Basics of ASP.NET

1. What is ASP?
Active Server Pages (ASP), also known as Classic ASP, is a Microsoft's server-side technology, which helps in creating dynamic and user-friendly Web pages. It uses different scripting languages to create dynamic Web pages, which can be run on any type of browser. The Web pages are built by using either VBScript or JavaScript and these Web pages have access to the same services as Windows application, including ADO (ActiveX Data Objects) for database access, SMTP (Simple Mail Transfer Protocol) for e-mail, and the entire COM (Component Object Model) structure used in the Windows environment. ASP is implemented through a dynamic-link library (asp.dll) that is called by the IIS server when a Web page is requested from the server.

2. What is ASP.NET?
ASP.NET is a specification developed by Microsoft to create dynamic Web applications, Web sites, and Web services. It is a part of .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as VBScript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.
3. What is the basic difference between ASP and ASP.NET?
The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).
4. In which event are the controls fully loaded?
Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event
5. How can we identify that the Page is Post Back?
Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.
6. What is the lifespan for items stored in ViewState?
The items stored in ViewState live until the lifetime of the current page expires including the postbacks to the same page.
Read More

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Blogroll