Firefox 目前给我带来了一些问题,我无法弄清楚。
我有两个列表框,一个在页面加载时填充,另一个在选择第一个项目时填充,然后单击查看按钮。我遇到的问题是第二个列表框仅填充一瞬间,然后所有内容都被删除。该功能适用于我测试过的所有其他浏览器.. IE、Chrome 和 Safari..
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
using DAL;
namespace ACESAdmin2.AcesSetup
{
public partial class storefront : System.Web.UI.Page
{
private string selectedCustomer
{
get { return Session["selectedCustomer"] != null ? (string)Session["selectedCustomer"] : string.Empty; }
set { Session["selectedCustomer"] = value; }
}
private string selectedCatalog
{
get { return Session["selectedCatalog"] != null ? (string)Session["selectedCatalog"] : string.Empty; }
set { Session["selectedCatalog"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadPage();
}
}
private void LoadPage()
{
initControls();
#region role setting
try
{
//check user role to determine editing rights
string usersRole = Roles.GetRolesForUser(Membership.GetUser().UserName)[0];
MembershipUser user = Membership.GetUser();
switch (usersRole)
{
case "BasicUser":
AlignTextNoneRadio.Enabled = false;
AlignTextLeftRadio.Enabled = false;
AlignRightRadio.Enabled = false;
AlignCenterRadio.Enabled = false;
headerText.Enabled = false;
returnPolicy.Enabled = false;
welcomeMessageTextBox.Enabled = false;
homeText.Enabled = false;
homeLink.Enabled = false;
updateStoreButton.Enabled = false;
break;
case "Customer":
homeLink.Enabled = false;
homeText.Enabled = false;
break;
case "SalesRep":
case "Admin":
case "SuperAdmin":
break;
default:
break;
}
}
catch (NullReferenceException error)
{
string message;
message = error.ToString();
Response.Redirect("../error.aspx");
}
#endregion
#region Accordion Pane Settings
if (ViewState["SelectedAccordionIndex"] == null)
{
MyAccordion.SelectedIndex = -1;
}
else
{
MyAccordion.SelectedIndex = (int)ViewState["SelectedAccordionIndex"];
}
#endregion
}
private void initControls()
{
//Viewable to all
#region customer label
if (selectedCustomer != null)
{
string customerName = DAL.Util.getCustomerName().ToString();
if (customerName != null || customerName != String.Empty)
{
lblCustomer.Text = "Customer: <font color=maroon>" + customerName + "</font>";
lblCustomer.Visible = true;
}
else
{
lblCustomer.Text = "Customer: <font color=maroon>" + selectedCustomer.ToString() + "</font>";
lblCustomer.Visible = true;
}
}
#endregion
//Edit Store Front
#region Populate Fields
#region headerAlign
string headerAlign = DAL.Util.getHeaderAlign().ToString();
switch (headerAlign)
{
case "left":
AlignTextLeftRadio.Checked = true;
break;
case "center":
AlignCenterRadio.Checked = true;
break;
case "right":
AlignRightRadio.Checked = true;
break;
default:
AlignTextNoneRadio.Checked = true;
break;
}
#endregion
welcomeMessageTextBox.Text = DAL.Util.getWelcome().ToString();
headerText.Text = DAL.Util.getHeaderText().ToString();
returnPolicy.Text = DAL.Util.getReturn().ToString();
homeLink.Text = DAL.Util.getHomeLink().ToString();
homeText.Text = DAL.Util.getHomeText().ToString();
#endregion
//BJIT Setup
#region popultae fields
ddlSelectVendor.DataSource = DAL.Util.getVendors();
ddlSelectVendor.DataBind();
listCatalogs.DataSource = DAL.Util.getCatalogs();
listCatalogs.DataBind();
#endregion
}
protected void returnButton_Click(object sender, EventArgs e)
{
//Takes user back to main admin page
Response.Redirect("../Admin/mainAdmin.aspx");
}
protected void dropdownlist_SelectedInexChange(object sender, EventArgs e)
{
ViewState["SelectedAccordionIndex"] = MyAccordion.SelectedIndex;
}
protected void updateStoreButton_Click(object sender, EventArgs e)
{
switch(MyAccordion.SelectedIndex)
{
case 0:
#region Header Value
string selectedHeaderAlign = null;
foreach (Control control in this.RadioPanel.Controls)
{
if (control is RadioButton)
{
RadioButton radio = control as RadioButton;
if (radio.Checked)
{
selectedHeaderAlign = radio.Text.ToLower();
}
}
}
#endregion
//updates customer information in the table
string sqlSf = "Update Store SET HeaderAlign = @HeaderAlign, HeaderText=@HeaderText, ReturnPolicy=@ReturnPolicy, WelcomeMessage=@WelcomeMessage, HomeTextLink=@HomeTextLink, HomeLink=@HomeLink"
+ " WHERE CustomerID='" + HttpContext.Current.Session["selectedCustomer"].ToString() + "'";
//setting parameters
#region Parameter Values
AdoUtil.ACESSQLParameterCollection parameters = new AdoUtil.ACESSQLParameterCollection();
AdoUtil.ACESSQLParameter param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@HeaderAlign";
param.ParamValue = selectedHeaderAlign.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@HeaderText";
param.ParamValue = headerText.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@ReturnPolicy";
param.ParamValue = returnPolicy.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@WelcomeMessage";
param.ParamValue = welcomeMessageTextBox.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@HomeTextLink";
param.ParamValue = homeText.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@HomeLink";
param.ParamValue = homeLink.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
#endregion
AdoUtil.ExecuteNonQuery(sqlSf, parameters);
break;
case 1:
//BJIT Updates
string sqlBJIT = "Update";
break;
default:
break;
}
MyAccordion.SelectedIndex = -1;
}
#region BJIT Control Events
//BJIT Button
protected void btnAddCustomer_Click(object sender, EventArgs e)
{
if (listItems.SelectedIndex != -1)
{
ArrayList removeArr = new ArrayList();
listItemProfiles.SelectedIndex = -1;
//Copy selected items to listItemProfiles
foreach (ListItem li in listItems.Items)
{
if (li.Selected)
{
listItemProfiles.Items.Add(li);
removeArr.Add(li);
}
}
//Remove the selected items from listItems
foreach (ListItem li in removeArr)
{
listItems.Items.Remove(li);
}
Util.WebFunctions.SortListBox(listItemProfiles);
}
}
//BJIT Button
protected void btnRemoveCustomer_Click(object sender, EventArgs e)
{
if (listItemProfiles.SelectedIndex != -1)
{
ArrayList removeArr = new ArrayList();
listItems.SelectedIndex = -1;
//Copy selected items to listItems
foreach (ListItem li in listItemProfiles.Items)
{
if (li.Selected)
{
li.Selected = false;
listItems.Items.Add(li);
removeArr.Add(li);
}
}
//Remove the selected items from listItemProfiles
foreach (ListItem li in removeArr)
{
listItemProfiles.Items.Remove(li);
}
Util.WebFunctions.SortListBox(listItems);
}
}
//BJIT Button
protected void viewBtn_Click(object sender, EventArgs e)
{
if (listCatalogs.SelectedItem != null)
{
listItemCatalogs.DataSource = DAL.Util.getCatalogProfile(listCatalogs.SelectedValue.ToString());
listItemCatalogs.DataBind();
}
}
//BJIT Button
protected void editBtn_Click(object sender, EventArgs e)
{
if (listCatalogs.SelectedItem != null)
{
#region controls visible
lblVendor.Visible = true;
ddlSelectVendor.Visible = true;
lblItemProfile.Visible = true;
lblItems.Visible = true;
listItems.Visible = true;
listItemProfiles.Visible = true;
btnAddCustomer.Visible = true;
btnRemoveCustomer.Visible = true;
lblItemsCatalog.Visible = false;
listItemCatalogs.Visible = false;
//listItemCatalogs.Items.Clear();
#endregion
#region disable controls
//listCatalogs.Enabled = false;
listItemCatalogs.Enabled = false;
editBtn.Enabled = false;
viewBtn.Enabled = false;
#endregion
listItemProfiles.DataSource = DAL.Util.getCatalogProfile(listCatalogs.SelectedValue.ToString());
listItemProfiles.DataBind();
}
}
//BJIT Drop Down List
protected void ddlSelectVendor_Changed(object sender, EventArgs e)
{
listItems.DataSource = DAL.Util.getVenorItems(ddlSelectVendor.SelectedItem.ToString());
listItems.DataBind();
}
#endregion
}
}
有了这个,还有一些以前没有描述过的功能,并且在这个 Firefox 中,当 editBtn_Click 启动时,它也不会保留数据/保持控件可见。
再说一次,如果有什么我可以澄清的,我会尽力改写或任何事情。
谢谢你。