Webpage submitting data to it self is called “post back submission”.
This requires only one webpage for accepting data and reading data. This allows reading data using controlid directly, Request object is not required.
EX: controlid.property name
[txtaccno.Text]
This requires logic with in button click sub program.
Creating website to work with postback submission:
Goto visual studio
Start->run->devenv
It will display main window of visual studio
File menu->new->website->visual c#->select asp.net empty website
Weblocation->e:\aspnet\banksite[drive:\dir\websitename]
Visual studio create a folder with website name, in this folder website related files will be placed
Add webform
Goto view menu and select solution explorer
Right click on website path and select add new item
Select webform
Give name as display.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="display.aspx.cs" Inherits="display" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Goto design part
Goto view menu and select toolbox
Expand standard tab and place 3 labels controls and 3 text boxes and button
Arrange controls as shown above diagram
Set the text property to all the labels as [accno,name,bal].
Id for all the controls will be default id.
Double click on button control, This will display button1 click sub program with in code view
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class display : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string[,] s = { { "1", "charan", "3000" }, { "2", "xyz", "10000" }, { "3", "raju", "20000" } };
bool b = false;
string accno = TextBox1.Text;
for (byte i = 0; i < 3; i++)
{
if (accno == s[i, 0])
{
TextBox2.Text = s[i, 1];
TextBox3.Text = s[i, 2];
b = true;
break;
}
}
if (b == false)
{
TextBox1.Text = " ";
Response.Write("<h2> accno not found </h2>");
}
}
}
Goto contrl F5 (shows output)
Note:
1)postbackurl property setting is not required for postback submission, It is required for postback submission, It is required for crosspage submission.
2)most of the implementation will be postback submission [traditional websites developed using asp were using crosspage submission. In the current scenario lot of implementation will be postback submission]
Image control:
This control can be used to display image on asp.net webform
Properties:
1.ID
2.image url-specify image filename (or) image url to be displayed with image control.
Hyperlink control:
1)hyperlink allows user to download a file from server system to client system
2)hyperlink can be text (or) image
Properties:
1)Id
2)text-specify hyperlink text
3)image url-specify hyperlink image
4)navigate url-specify filename to be downloaded