Hi, I'm going crazy here, please help. I have a parent page that has a
user control on it that bubbles up data from a dropdown menu. The drop
down menus are populated by a set of radio buttons, each populates the
drop downs with unique data. All works well, you check a radio button
and the onbubbleevent fires loading the drop downs. A user can then
select an item from the drop down and be forwarded (Respose.Redirect)
to the appropriate detail page.
Here is the problem. If the user goes to a detail page, then uses the
browser back button and goes back to the main page, selects a
differnet radio button, the onbubbleevent fires before the drop downs
are populated with the corresponding radio button data. This results
in an error because the drop downs have the wrong data for the
selected radio button.
I tried to just prevent the page from caching, but that resulted in a
"Warning: Page has Expired" window which I really don't like. It seems
like this should be easy, I just need the radio button function to
always fire first! The wierd thing is that I test to see if the sender
is a drop down menu in the bubble event and it still fires when a
radio button is selected (only when someone uses the browser back
button after selecting an item from one of the drop downs). Please
help, code is below.
Thanks
This is the Main Parent page:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
namespace MyPage
{
/// <summary>
/// Summary description for index.
/// </summary>
public class index : System.Web.UI.Page
{
protected RadioButton Btn1, Btn2, Btn3, Btn4;
protected MyPage.dropdownsearch SearchMenus;
protected string TheId, ButtonOn, LastButtonOn;
protected MyPage.globalnav MenuItems;
protected HyperLink ResourceUrl;
private void Page_Load(object sender, System.EventArgs e)
{
}
protected override bool OnBubbleEvent(object sender, EventArgs e)
{
if(sender != null && sender is DropDownList)
{
DropDownList temp = (DropDownList)sender;
if(temp.ID.Equals("TradeNames"))
{
TheId = "TradeNames="+SearchMenus.TradeNames.SelectedItem. Value;
ForwardThePage();
}
if(temp.ID.Equals("Applications"))
{
TheId = "Applications="+SearchMenus.Applications.SelectedI tem.Value;
ForwardThePage();
}
if(temp.ID.Equals("Processes"))
{
TheId = "Processes="+SearchMenus.Processes.SelectedItem.Va lue;
ForwardThePage();
}
}
return true;
}
protected void ForwardThePage()
{
if (Btn1.Checked)
{
Response.Redirect("btn1/index.aspx?"+TheId);
}
if (Btn2.Checked)
{
Response.Redirect("btn2/index.aspx?"+TheId);
}
if (Btn3.Checked)
{
Response.Redirect("btn3/index.aspx?"+TheId);
}
if (Btn4.Checked)
{
Response.Redirect("btn4/index.aspx?"+TheId);
}
}
protected void CategorySelected(object sender, System.EventArgs e)
{
if (Btn1.Checked)
{
MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=1";
SearchMenus.SqlCat = "1";
SearchMenus.DbCall();
}
if (Btn2.Checked)
{
MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=2";
SearchMenus.SqlCat = "2";
SearchMenus.DbCall();
}
if (Btn3.Checked)
{
MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=4";
SearchMenus.SqlCat = "3";
SearchMenus.DbCall();
}
if (Btn4.Checked)
{
MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=3";
SearchMenus.SqlCat = "4";
SearchMenus.DbCall();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
This is the Drop Down User Control:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
namespace MyPage
{
/// <summary>
/// Summary description for tier.
/// </summary>
public class dropdownsearch : System.Web.UI.UserControl
{
SqlConnection SearchConnection;
protected DataSet MyDataSet = new DataSet();
public DropDownList TradeNames, Applications, Processes;
protected string Url;
private string _SqlCat;
protected Label MyLabel;
SqlCommand MyCommand;
public string SqlCat
{
get
{
return _SqlCat;
}
set
{
_SqlCat = value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
}
}
public void TradeClear(object sender, System.EventArgs e)
{
Applications.SelectedIndex = 0;
Processes.SelectedIndex = 0;
RaiseBubbleEvent(sender, e);
}
public void ApplicationClear(object sender, System.EventArgs e)
{
TradeNames.SelectedIndex = 0;
Processes.SelectedIndex = 0;
RaiseBubbleEvent(sender, e);
}
public void ProcessClear(object sender, System.EventArgs e)
{
Applications.SelectedIndex = 0;
TradeNames.SelectedIndex = 0;
RaiseBubbleEvent(sender, e);
}
public void DbCall()
{
SearchConnection = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
string MySqlStatement = "sp_DropDownsSql " +SqlCat+", "+SqlCat;
MyCommand = new SqlCommand(MySqlStatement, SearchConnection);
SearchConnection.Open();
SqlDataReader MyReader = MyCommand.ExecuteReader();
TradeNames.DataSource = MyReader;
TradeNames.DataValueField = "TradeId";
TradeNames.DataTextField = "TradeNames";
TradeNames.DataBind();
TradeNames.Items.Insert(0, new ListItem("---------------Search By
Trade Name-------------"));
MyReader.NextResult();
Applications.DataSource = MyReader;
Applications.DataValueField = "ApplicationId";
Applications.DataTextField = "Application";
Applications.DataBind();
Applications.Items.Insert(0, new ListItem("---------------Search By
Application------------"));
MyReader.NextResult();
Processes.DataSource = MyReader;
Processes.DataValueField = "ProcessId";
Processes.DataTextField = "Processes";
Processes.DataBind();
Processes.Items.Insert(0, new ListItem("---------------Search By
Process----------------"));
MyReader.NextResult();
MyReader.Close();
SearchConnection.Close();
TradeNames.SelectedValue = Request.QueryString["TradeNames"];
Applications.SelectedValue = Request.QueryString["Applications"];
Processes.SelectedValue = Request.QueryString["Processes"];
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.TradeNames.SelectedIndexChanged += new
System.EventHandler(this.TradeClear);
this.Applications.SelectedIndexChanged += new
System.EventHandler(this.ApplicationClear);
this.Processes.SelectedIndexChanged += new
System.EventHandler(this.ProcessClear);
}
#endregion
}
} 5 2400
Save each Reader into a Session.
try{
string MySqlStatement;
if(Session["MySqlStatement"] !=null){
MySqlStatement = "sp_DropDownsSql " +SqlCat+", "+SqlCat;
Session["MySqlStatement"] = MySqlStatement ;
}
else MySqlStatement = (string)Session["MySqlStatement"] ;
}
catch(Exception){}
finally{}
Use this logic but make sure to remove the Session at some point somewhere
in your logic.
Hope this helps,
Yama
NOTE:
You should never use sp_StoredProcedureName because the sp_ is queried
through master database.
"Dan" <dp********@masonmadison.com> wrote in message
news:2a**************************@posting.google.c om... Hi, I'm going crazy here, please help. I have a parent page that has a user control on it that bubbles up data from a dropdown menu. The drop down menus are populated by a set of radio buttons, each populates the drop downs with unique data. All works well, you check a radio button and the onbubbleevent fires loading the drop downs. A user can then select an item from the drop down and be forwarded (Respose.Redirect) to the appropriate detail page.
Here is the problem. If the user goes to a detail page, then uses the browser back button and goes back to the main page, selects a differnet radio button, the onbubbleevent fires before the drop downs are populated with the corresponding radio button data. This results in an error because the drop downs have the wrong data for the selected radio button.
I tried to just prevent the page from caching, but that resulted in a "Warning: Page has Expired" window which I really don't like. It seems like this should be easy, I just need the radio button function to always fire first! The wierd thing is that I test to see if the sender is a drop down menu in the bubble event and it still fires when a radio button is selected (only when someone uses the browser back button after selecting an item from one of the drop downs). Please help, code is below. Thanks This is the Main Parent page:
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Configuration;
namespace MyPage { /// <summary> /// Summary description for index. /// </summary> public class index : System.Web.UI.Page { protected RadioButton Btn1, Btn2, Btn3, Btn4; protected MyPage.dropdownsearch SearchMenus; protected string TheId, ButtonOn, LastButtonOn; protected MyPage.globalnav MenuItems; protected HyperLink ResourceUrl;
private void Page_Load(object sender, System.EventArgs e) {
}
protected override bool OnBubbleEvent(object sender, EventArgs e) {
if(sender != null && sender is DropDownList) {
DropDownList temp = (DropDownList)sender; if(temp.ID.Equals("TradeNames")) { TheId = "TradeNames="+SearchMenus.TradeNames.SelectedItem. Value; ForwardThePage(); }
if(temp.ID.Equals("Applications")) { TheId = "Applications="+SearchMenus.Applications.SelectedI tem.Value; ForwardThePage(); }
if(temp.ID.Equals("Processes")) { TheId = "Processes="+SearchMenus.Processes.SelectedItem.Va lue; ForwardThePage(); } } return true; } protected void ForwardThePage() { if (Btn1.Checked) { Response.Redirect("btn1/index.aspx?"+TheId); }
if (Btn2.Checked) { Response.Redirect("btn2/index.aspx?"+TheId);
}
if (Btn3.Checked) { Response.Redirect("btn3/index.aspx?"+TheId); }
if (Btn4.Checked) { Response.Redirect("btn4/index.aspx?"+TheId); } }
protected void CategorySelected(object sender, System.EventArgs e) {
if (Btn1.Checked) { MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=1"; SearchMenus.SqlCat = "1"; SearchMenus.DbCall(); }
if (Btn2.Checked) { MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=2"; SearchMenus.SqlCat = "2"; SearchMenus.DbCall(); }
if (Btn3.Checked) { MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=4"; SearchMenus.SqlCat = "3"; SearchMenus.DbCall(); }
if (Btn4.Checked) { MenuItems.ResourceUrl.NavigateUrl = "resources.aspx?CatId=3"; SearchMenus.SqlCat = "4"; SearchMenus.DbCall(); }
}
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } This is the Drop Down User Control:
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Configuration;
namespace MyPage { /// <summary> /// Summary description for tier. /// </summary> public class dropdownsearch : System.Web.UI.UserControl { SqlConnection SearchConnection; protected DataSet MyDataSet = new DataSet(); public DropDownList TradeNames, Applications, Processes; protected string Url; private string _SqlCat; protected Label MyLabel; SqlCommand MyCommand;
public string SqlCat { get { return _SqlCat; } set { _SqlCat = value; } }
private void Page_Load(object sender, System.EventArgs e) {
if(!IsPostBack) {
}
}
public void TradeClear(object sender, System.EventArgs e) { Applications.SelectedIndex = 0; Processes.SelectedIndex = 0; RaiseBubbleEvent(sender, e); }
public void ApplicationClear(object sender, System.EventArgs e) { TradeNames.SelectedIndex = 0; Processes.SelectedIndex = 0; RaiseBubbleEvent(sender, e); }
public void ProcessClear(object sender, System.EventArgs e) { Applications.SelectedIndex = 0; TradeNames.SelectedIndex = 0; RaiseBubbleEvent(sender, e); }
public void DbCall() { SearchConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); string MySqlStatement = "sp_DropDownsSql " +SqlCat+", "+SqlCat;
MyCommand = new SqlCommand(MySqlStatement, SearchConnection); SearchConnection.Open(); SqlDataReader MyReader = MyCommand.ExecuteReader();
TradeNames.DataSource = MyReader; TradeNames.DataValueField = "TradeId"; TradeNames.DataTextField = "TradeNames"; TradeNames.DataBind(); TradeNames.Items.Insert(0, new ListItem("---------------Search By Trade Name-------------")); MyReader.NextResult();
Applications.DataSource = MyReader; Applications.DataValueField = "ApplicationId"; Applications.DataTextField = "Application"; Applications.DataBind(); Applications.Items.Insert(0, new ListItem("---------------Search By Application------------")); MyReader.NextResult();
Processes.DataSource = MyReader; Processes.DataValueField = "ProcessId"; Processes.DataTextField = "Processes"; Processes.DataBind(); Processes.Items.Insert(0, new ListItem("---------------Search By Process----------------")); MyReader.NextResult();
MyReader.Close(); SearchConnection.Close();
TradeNames.SelectedValue = Request.QueryString["TradeNames"]; Applications.SelectedValue = Request.QueryString["Applications"]; Processes.SelectedValue = Request.QueryString["Processes"];
} #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.TradeNames.SelectedIndexChanged += new System.EventHandler(this.TradeClear); this.Applications.SelectedIndexChanged += new System.EventHandler(this.ApplicationClear); this.Processes.SelectedIndexChanged += new System.EventHandler(this.ProcessClear); } #endregion
} }
Hi Yama, thanks for the response. Unfortunately, I'm trying to avoid
using session variables. Do you know of any way to just make certain the
radio buttons function fires before the onbubbleevent? Thanks for the sp
tip too;)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Okay... Well then try to load the combobox on the Page_Init in your main
page...
"Dan Poincelot" <dp********@masonmadison.com> wrote in message
news:uf****************@TK2MSFTNGP10.phx.gbl... Hi Yama, thanks for the response. Unfortunately, I'm trying to avoid using session variables. Do you know of any way to just make certain the radio buttons function fires before the onbubbleevent? Thanks for the sp tip too;)
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Hi Yama, do you mean load the radio buttons in the page_init and that
will make them fire first when clicked? If so, how do you load them
there?
Thanks for your help.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Hi Yama, are you saying to load the radio buttons in the page_init and
that will make their function fire first, before the drop downs
onbubbleevent? If so, how do I do this?
Thanks for your help.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: A. Elamiri |
last post by:
Hello,
For some reason the FileSystemWatcher events aren't firing. The code that
sets the event delegates
....
asmwatch.Path = AppDomain.CurrentDomain.BaseDirectory + "services\\";
...
|
by: Andreas Klemt |
last post by:
Hello,
I have this
Protected Overrides Function OnBubbleEvent(ByVal source As Object, ByVal
args As System.EventArgs) As Boolean
a) Return True
b) Return False
c) Doing nothing...
End...
|
by: Andreas Klemt |
last post by:
Hello,
why is OnBubbleEvent on my Parent Page fired even when I didn't do
RaiseBubbleEvent in UserControl Page?
When I Call RaiseBubbleEvent in the UserControl,
OnBubbleEvent is called twice...
|
by: jim corey |
last post by:
I have a page that has a button and there is also a usercontrol on the
page
which has an OK and Cancel button.
I'm looking at ways to trigger an event on the parent page when
the child...
|
by: Pat |
last post by:
Hi all:
I have a custom datagrid that has a row of buttons in its header (it
serves as a toolbar).
I'm overriding the OnBubbleEvent to handle the clicks for these child
buttons.
However,...
|
by: SirPoonga |
last post by:
I have a form with several DropDowns and DataGrids. They all work the
way they are suppose except one dropdown. When I select an option it's
SelectedIndexChanged event is not firing. When the page...
|
by: ~~~ .NET Ed ~~~ |
last post by:
I have a problem (don't we all?). I have a web form with multiple modules,
some of these modules have an ASP.NET (server run) button.
OK, now I have UserControlX which has one such button (say...
|
by: jake |
last post by:
I am new to multi-threading. Here is my scenario:
foreach (<file in a certain folder>)
new Thread((ThreadStart)(delegate { processFile(<file>); })).Start();
sometimes misses firing some...
|
by: brucedodds |
last post by:
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying the
form rather than firing the OnClick event. Does anyone have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |