This post is a follow up from the original post dated Oct 16, 2004 "I have
this problem, pls help!" created by Paul FI.
These bugs are rather serious and we would like to know how to get around.
Environment: Windows XP Pro. IIS-5 and Sp2.
Visual Studio.Net 2003 EA edition.
..NetFW 1.1
Here goes:
The followings are steps to reproduce two serious bugs found by Paul and
John within Asp.Net application. The application is a c# and consists of the
following items:
1. Web site: http://LocalHost/tBug
2. Four Asp.Net forms: WebForm1.Aspx (Default page), WebForm2.Aspx,
WebForm3.Aspx, and WebForm4.Aspx
Steps:
1. Create a new c-sharp (c#) Asp.Net web Project called tBug.
2. Drop a "Drop Down List Component" on WebForm1.aspx and call it "DDL", and
enable its "AutoPostBa ck".
3. Add 3 items to the DDL called Test1, Test2 and Test3 for their "Text"
property. Assign 1, 2 and 3 to their "Value" property accordingly.
4. Drop a Label compoment beside the DDL.
5. Drop two Button components on WebForm1 under the DDL and call them
Button1(Text=To WebForm2) & Button2 (Text=ToWebForm 3).
6. Double-Click on the WebForm1 itself and copy this code below onto your
WebForm1.onPage Load event:
private void Page_Load(objec t sender, System.EventArg s e)
{
if(!this.IsPost Back)
{
Label1.Text="We lcome to New tBug";
return;
}
Label1.Text="I am Back";
}
7. Double-Click on the WebForm1.DDL and copy this code below onto your
WebForm1.DDL_Se lectedIndexChan ged event:
private void DDL_SelectedInd exChanged(objec t sender, System.EventArg s
e)
{
Response.Redire ct("WebForm4.as px");
}
8. Double-Click on the WebForm1.Button 1 and copy this code below onto your
WebForm1.Button 1_Click event:
private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm2.as px");
}
9. Double-Click on the WebForm1.Button 2 and copy this code below onto your
WebForm1.Button 2_Click event:
private void Button2_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm3.as px");
}
10. On the Solution Explorer, right-click on the "tBug" project and select
Add/New Asp.Net Form. Name it "WebForm2".
11. Repeat Step 10 above for WebForm3 and WebForm4.
12. Bringup WebForm2 and drop a Label component on its design surface and
assign "This is WebForm2" to its Text property.
13. Bringup WebForm3 and drop a Label component on its design surface and
assign "This is WebForm3" to its Text property.
14. Bringup WebForm4 and drop a Label component on its design surface and
assign "This is WebForm4" to its Text property.
15. Build the sulution and run it.
How to see the described BUGS:
16. Once the application is shown on the MS/IE, you should see the
Label1.Text has "Welcome to new tBug" as expected.
17. Select "Test2" from the DDL. This will bring you to WebForm4.aspx as
expected.
18. Click the "Back" button from the MS/IE tool bar. This will bring you
back to WebForm1.aspx as expected.
19. Click the "ToWebForm2 or 3" button on WebForm1, this should bring you to
"WebForm2 or 3" but "WebForm4" is shown instead.This is the "BUG" that Paul
FI talked about.
20. Click the "Back" button to go back to WebForm1 as expected.
21. Select "Test1" from the DDL, this should bring you to WebForm4, instead,
it shows "I am Back" on Webform1. This is a new BUG I found.
*************** *************** *************** ********
Below is a complete c# code-behind for WebForm1.aspx.
*************** *************** *************** ********
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace tBug
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l Label1;
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Butt on Button2;
protected System.Web.UI.W ebControls.Labe l Label2;
protected System.Web.UI.W ebControls.Drop DownList ddl;
private void Page_Load(objec t sender, System.EventArg s e)
{
if(!this.IsPost Back)
{
Label1.Text="We lcome to New tBug";
return;
}
Label1.Text="I am Back";
}
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{
this.ddl.Select edIndexChanged += new
System.EventHan dler(this.ddl_S electedIndexCha nged);
this.Button1.Cl ick += new System.EventHan dler(this.Butto n1_Click);
this.Button2.Cl ick += new System.EventHan dler(this.Butto n2_Click);
this.Load += new System.EventHan dler(this.Page_ Load);
}
private void ddl_SelectedInd exChanged(objec t sender, System.EventArg s
e)
{
Response.Redire ct("WebForm4.as px");
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm2.as px");
}
private void Button2_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm3.as px");
}
}
}
Thanks for your help,
John Webb