Hi
I have developed a web page with some controls. I put all of them in
session variables. I passed this values in the page. When an user
enter some data in form fields and click the buttton , these values
are displaying in next page.after displaying in next page, when click
back button to see my entered values for change , no values are in the
form fields. the fields are empty .I tried with enable view state=true
in controls and at the top of the page.but it doesn't work.
any one help would be appriciated.
Here is the code in two pages.
--------------------------------------------------------------------------------------------------
Default.aspx
<%@ Page Language="C#" AutoEventWireup ="true"
CodeBehind="Def ault.aspx.cs" Inherits="WebAp plication2._Def ault" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body bgcolor="bule">
<form id="form1" runat="server">
<div>
<table cellspacing="1" >
<tr>
<td colspan="300px" >
<table width="700px" border="1">
<tr>
<td>
<tr align="center">
<td align ="center">
<asp:Label ID="lblusername "
runat="server"> FirstName :</asp:Label>
<asp:TextBox ID="txtusername "
runat="server" Width="100px"></asp:TextBox>
</td>
</tr>
<tr align="center">
<td align="center" bgcolor="Fuchsi a">
<asp:Label ID="lblpassword "
runat="server"> LastName :</asp:Label>
<asp:TextBox ID="txtpassword "
runat="server" Width="100px"></asp:TextBox>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Label ID="lblcity"
runat="server"> City :</asp:Label>
<asp:TextBox ID="txtcity" runat="server"
Width="100px"></asp:TextBox>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Label ID="lblstate" BackColor="Aqua "
runat="server"> State :</asp:Label>
<asp:DropDownLi st runat="server"
ID="ddlstate">
<asp:ListItem Text="AZ"/>
<asp:ListItem Text="AL"/>
<asp:ListItem Text="CA"/>
<asp:ListItem Text="DL"/>
<asp:ListItem Text="FL"/>
<asp:ListItem Text="GA"/>
<asp:ListItem Text="IL"/>
<asp:ListItem Text="KE"/>
<asp:ListItem Text="MN"/>
<asp:ListItem Text="ND"/>
<asp:ListItem Text="OH"/>
<asp:ListItem Text="PA"/>
<asp:ListItem Text="SD"/>
<asp:ListItem Text="TX"/>
<asp:ListItem Text="UT"/>
<asp:ListItem Text="VA"/>
</asp:DropDownLis t>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Label ID="lblzip"
runat="server"> Zip :</asp:Label>
<asp:TextBox ID="txtzip" runat="server"
Width="100px"></asp:TextBox>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Label ID="lblphone"
runat="server"> Phone :</asp:Label>
<asp:TextBox ID="txtphone" runat="server"
Width="100px" BackColor="#009 9FF"></asp:TextBox>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Label ID="Label1"
runat="server"> Codeword :</asp:Label>
<asp:DropDownLi st ID="ddlselect"
runat="server" ForeColor="Blue "
BackColor="#FFC CFF">
<asp:ListItem Text=""/>
<asp:ListItem Text="What is your favourite
pet?."/>
<asp:ListItem Text="What is your favourite
country?."/>
<asp:ListItem Text="What is your favourite
movie?."/>
<asp:ListItem Text="What is your favourite
movie?."/>
<asp:ListItem Text="What is your maiden
father name?."/>
</asp:DropDownLis t>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Label ID="lblcodeword "
runat="server"> </asp:Label>
<asp:TextBox ID="txtcodeword "
runat="server" Width="100px" BackColor="Blue Violet"></asp:TextBox>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Button ID="btnok" runat="server"
Text="Submit" onclick="btnok_ Click" />
</td>
</tr>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------
Default.aspx.cs
using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;
using System.Data.Sql Client;
namespace WebApplication2
{
public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Page.EnableView State = true;
}
protected void btnok_Click(obj ect sender, EventArgs e)
{
Session["first"] = txtusername.Tex t.Trim();
Session["last"] = txtpassword.Tex t.Trim();
Session["city"] = txtcity.Text.Tr im();
Session["state"] = ddlstate.Select edValue.ToStrin g();
Session["zip"] = txtzip.Text.Tri m();
Session["phone"] = txtphone.Text.T rim();
Session["selectcodeword "] =
ddlselect.Selec tedValue.ToStri ng();
Session["entercodew ord"] = txtcodeword.Tex t.Trim();
Response.Redire ct("WebForm1.as px");
}
}
}
----------------------------------------------------------------------------------------------------
WebForm1.aspx.
using System;
using System.Collecti ons;
using System.Configur ation;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.H tmlControls;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Xml.Linq ;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
string firstname = Session["first"].ToString();
string lastname = Session["last"].ToString();
string cityname = Session["city"].ToString();
string statename = Session["state"].ToString();
string zipcode = Session["zip"].ToString();
string phonenumber = Session["phone"].ToString();
string selectanycodewo rd =
Session["selectcodeword "].ToString();
string enteranycodewor d =
Session["entercodew ord"].ToString();
Response.Write( "you entered :" + "</br>");
Response.Write( "FirstName :" + firstname + "</br>");
Response.Write( "LastName : " + lastname + "</br>");
Response.Write( "CodeWord : " + selectanycodewo rd + "</
br>");
Response.Write( enteranycodewor d + "</br>");
Response.Write( "CityName : " + cityname + "</br>");
Response.Write( "StateName : " + statename + "</br>");
Response.Write( "Zipcode : " + zipcode + "</br>");
Response.Write( "Phone Number :" + phonenumber);
}
protected void btnupdate_Click (object sender, EventArgs e)
{
Response.Redire ct("Default.asp x");
}
protected void btnok_Click(obj ect sender, EventArgs e)
{
Response.Redire ct("WebForm2.as px");
}
}
} 0 2860 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Phillips |
last post by:
I have a Panel control containing a few TextBox controls. The Panel is
originally enabled, I enter data into the TextBox controls. When I submit,
the Panel is disabled during the PostBack and the TextBox controls render
greyed-out, and I can see the values in the TextBox controls....this is what
I expected.
I submit again, the Panel is enabled during the PostBack. All of the
TextBox controls within the Panel are now enabled, however,...
|
by: Newasps |
last post by:
Hi guys,
I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the first values for each control. Please help me. Thanks for any help. Bye
Ozer
And here's my code:
Imports System
Imports System.Data
Imports System.Data.OleDb
|
by: Ozer |
last post by:
Hi guys,
I need some help. In my datagrid's updatecommand event i'm trying to get textboxes values and also do it. But when i update the values in textboxes and fire the event, I can't get the updated values. Please help me. Thanks for any help. Bye.
Ozer
And here's my code:
Imports System
Imports System.Data
Imports System.Data.OleDb
|
by: Tom wilson |
last post by:
Yes, I'm sorry, it's me again. :)
Yesterday I went through hell trying to figure out why my aspx pages
wouldn't maintain state. I had a simple example I (we) eventually got
to work.
What I've discovered is that my problem seems to lie entirely with IE.
A bit of history...
My app is an online survey. The questions, choices and so on are
|
by: Kiran Kumar Pinjala |
last post by:
Hi,
May be this is silly, or I just need a second pair eyes to look at this.
I am trying to get values that I have edited in a datagrid and update the
values with those values. Here is the code that I am using in my update
command.
TextBox txtProdName = (TextBox)e.Item.Cells.Controls;
TextBox txtSuppID = (TextBox)e.Item.Cells.Controls;
TextBox txtCatID = (TextBox)e.Item.Cells.Controls;
| |
by: Pipo |
last post by:
Nobody knows how to get the values provided in the client can be read in the
user-control?
If have made a Web Custom Control with 2 textboxes and 1 dropdownlist.
The user fills in my control (the textboxes and the dropdownlist) and lots
more stuff on the page.
When the user wants to save the page he'll click the save button.
The server gets the postback but I can read out the filled in controls (in
my control).
The textboxes text = ""...
|
by: rockdale |
last post by:
Hi, All:
I dynamic add an arrow up/down image in OnItemDataBound event for my
datagrid, it works fine. But I have another textbox which trigger
postback and doing something, after this event get executed, I lost the
image but the datagrid maintain the same sort order. Should the
datagrid remain what it looks like (with the riget arrow up/down image)
before the postback caused by the textbox?
|
by: Andy B |
last post by:
I have this code:
protected void EditEventsWizard_NextButtonClick(object sender,
WizardNavigationEventArgs e) {
//get the values from the DetailsView
TextBox StartTime = (TextBox)EditEventForm.Rows.Cells.Controls;
TextBox EndTime = (TextBox)EditEventForm.Rows.Cells.Controls;
|
by: bgernon |
last post by:
I have a table that consists of two rows with three cells each row. The cells contain textboxes. I am able to successfully add a new row with textboxes when a button is clicked. The problem is retaining the newly added row with the filled in textboxes on the next button click. I think I am handling my viewstate incorrectly.
This code adds the new row:
Private Sub addRowsInTable()
Dim TextID As Integer
Dim TextIDCount...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |