我的问题是,SelectedIndexChanged of ddlObra控件没有启动,但是当我擦除Page.ClientScript.RegisterOnSubmitStatement of Page_Load时,一切都正常。我不能理解这种行为。
以下是代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CarregarDropDownLists();
}
Page.ClientScript.RegisterOnSubmitStatement(Page.GetType(), "OnSubmitScript", "return handleSubmit()");
}
protected void ddlObra_SelectedIndexChanged(object sender, EventArgs e)
{
List<Entidades.Empreendimento.Unidade> unidades = Entidades.Empreendimento.Unidade.ListaUnidades(txtLogin.Text);
ddlBloco.Items.Clear();
ddlUnidade.Items.Clear();
ddlBloco.Items.Insert(0, new ListItem("----- Bloco -----", ""));
ddlUnidade.Items.Insert(0, new ListItem("----- Unidade -----", ""));
//if (unidades.Count == 1) return;
foreach (Entidades.Empreendimento.Unidade Un in unidades)
{
if (Un.ObraVinculo.idObraCrm.ToString() == ddlObra.SelectedValue)
{
if (!ddlBloco.Items.Contains(new ListItem(Un.BlocoCRM.Nome, Un.BlocoCRM.CodigoCRM)))
{
ddlBloco.Items.Add(new ListItem(Un.BlocoCRM.Nome, Un.BlocoCRM.CodigoCRM));
}
Bandeira = Un.Bandeira;
Estado = Un.Estado;
}
}
ddlBloco.SelectedIndex = 0;
ddlUnidade.SelectedIndex = 0;
LoadAreas();
}此代码位于.aspx文件中。
<script type="text/javascript">
function handleSubmit() {
if (typeof (ValidatorOnSubmit) == 'function' && ValidatorOnSubmit() == false) {
return false;
} else {
$("#btnEnviar").click(function () { return false }).fadeTo(200, 0.5);
return true;
}
}
</script>谢谢你们的帮助!
发布于 2013-03-13 14:49:46
提交表单所执行的客户端脚本必须返回true,以便允许表单提交。这使客户端脚本能够有条件地阻止表单的提交。
https://stackoverflow.com/questions/15387533
复制相似问题