有一个弹出模式,具有与单选按钮和波纹管不同的披萨大小,下面是一个选择风味列表框,该列表框根据大小显示风味。我想根据选定的单选按钮更改显示尺寸。但是弹出模式关闭。我使用jquery以及ScriptManager和UpdatePanel进行了尝试,但是它不允许选择其他大小,只能选择默认值(选择小尺寸)。
<head>
<body>
<form>
<a href="#" data-toggle="modal" data-target="#pizzaModal">
<p>Pizza</p>
<img src="../dist/img/dashboardIcons/pizza.png" width="70" height="70" />
<div class="modal fade" id="pizzaModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-
label="Close">
</button>
</div>
<div class="modal-body">
<div class="row-fluid">
<div class="card card-danger">
<div class="card-header">
<h3 class="card-title">Select Size</h3>
</div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal"
OnSelectedIndexChanged="rblPizza_SelectedIndexChanged" AutoPostBack="true">
</asp:RadioButtonList>
</div>
</div>
<h3 class="card-title">Select Flavour</h3>
</div>
<div class="card-body">
<asp:ListBox runat="server" ID="ListBox1" SelectionMode="Multiple">
</asp:ListBox>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="btnSavePizza">Save
changes</button>
</div>
</div>
</div>
</div>
</form>
</body>
</head>
enter code here
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string pizzaModal = lblPizzaModal.Text;
if (pizzaModal != "" && pizzaModal != null)
{
BindSizeList(pizzaModal, rblPizza);
BindFlavourList(pizzaModal, lstBoxPizzaFlavour);
}
}
else
{
int a = 10;
//need to stop modal from closing in this section
}
}
protected void rblPizza_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["DBCON"].ToString());
SqlCommand command = new SqlCommand("sp_SelectProductFlavourSize", con);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@SizeId", 1);
con.Open();
SqlDataAdapter adpt = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adpt.Fill(ds);
lstBoxPizzaFlavour.DataSource = ds;
lstBoxPizzaFlavour.DataTextField = "Name";
lstBoxPizzaFlavour.DataValueField = "FlavourId";
lstBoxPizzaFlavour.DataBind();
con.Close();
}
答案 0 :(得分:-1)
您必须保存模式状态,因为每当触发postback
调用时,javascript/html
就会重新加载到页面上,并且您可能fallback
进入页面的默认状态。我建议每次在从C# codebehind
发回页面时,手动添加类(负责显示模式)。
编辑
我不确定为什么在不简要说明原因的情况下将其否决?