1
Firefox目前對我造成了一些問題,我無法弄清楚它們。未在Firefox中填充列表框
我有兩個列表框,一個是在頁面加載時填充的,另一個是當第一個項目被選中時,然後點擊查看按鈕。我遇到的問題是第二個列表框僅填充一秒鐘,然後刪除所有內容。該功能在我測試的所有其他瀏覽器IE ..,鉻,和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, [email protected], [email protected], [email protected], [email protected], [email protected]"
+ " 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啓動時保持控件可見。
再次,如果有什麼我可以清理,我會盡我所能來reword或任何東西。
謝謝。
如果它填充了一秒鐘,它可能是你有一些客戶端JavaScript清除我們的值 –
Dave首先要檢查的好評。此外,您是否正在使用可能正在進行另一個回調的ASP.NET Ajax?/您是否在頁面中的任何其他位置清除了值(即Page_Load事件)中的代碼。如果你這樣做,那麼設置一些斷點或者在那裏放置調試行將會很方便,以確保這些斷點在事後不會被執行。 –
您確實在page_load事件中有任何javascript或任何代碼?如果是回傳,你是否在做任何事情?你能把你的完整代碼放在這裏嗎?謝謝 – hjgraca