Error while using html controls

G

Guest

Hello,
I am developing an asp.net website. I have a web fomr say'
webform1.aspx' having two input button html controls. When I click on
'button1' a message appears. Following code is executed o client side

button1_click( )
{
document.webform1.submit( );
}

and on server side the message is assigned th a label in page_load method.

When a user clicks on other control, the page is redirected to other webform
say' webform2.aspx'.

The problem is as follows -

Now when I click on 'button1' for the first time, I get the message printed
on the label.Then when I click on 'button2', webform2.aspx is also displayed
but now if I click the 'Back' menu of the browser, I again get
'webform1.aspx'. Now if I click on 'button1' again then instead of displaying
text message on the label the page redirects to Webform2.aspx'.

Can any one help me to solve the problem

Thanks,
Sushi
 
D

DalePres

Post the code that you're using to set the label when button1 is clicked and
the code that you are using to redirect the client when button2 is clicked.

DalePres
 
G

Guest

Hello,

Code for webform1.aspx

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="true"
Inherits="WebApplication1.Namespace.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="vs_showGrid" content="False">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script id="clientEventHandlersJS" language="javascript">
<!--
function btn1_onclick() {
document.frm1.operation.value = "btn1";
document.frm1.submit( );
}

//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form method="post" runat="server" id="frm1">
<input type="hidden" name="operation"> <INPUT id="btn1" style="Z-INDEX:
101; LEFT: 112px; POSITION: absolute; TOP: 112px" type="button"
value="Button1" language=javascript onclick="return
btn1_onclick()"><INPUT id="btn2" style="Z-INDEX: 102; LEFT: 208px; POSITION:
absolute; TOP: 112px" type="button"
value="Button2" runat="server">
<asp:Label id="Label1" style="Z-INDEX: 103; LEFT: 24px; POSITION:
absolute; TOP: 64px" runat="server">Label</asp:Label>
</form>
</body>
</HTML>


Code for webform1.aspx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;

namespace WebApplication1.Namespace
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputButton btn2;
protected System.Web.UI.WebControls.Label Label1;

private void Page_Load(object sender, System.EventArgs e)
{
string operation = Request.Params["operation"];
if( operation != null )
{
if( operation.ToLower( ) == "btn1" )
{
Label1.Text = "hi";
}
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{ InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.btn2.ServerClick += new
System.EventHandler(this.btn2_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btn2_ServerClick(object sender, System.EventArgs e)
{
Response.Redirect("WebForm2.aspx");
}
}
}


Webform2.aspx is any normal aspx page.

Sushi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top