从代码隐藏打开引导模式 [英] Open Bootstrap Modal from code-behind

查看:19
本文介绍了从代码隐藏打开引导模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何从后面的代码中打开 twitter 引导模式?

Anyone knows how to open a twitter bootstrap modal, from code behind?

我想在保存时根据一些要求打开模式.诸如嘿,没有库存,选择以下选项之一以继续(丢弃,保留...)并按下该按钮(可能会回发以继续)"

I want to open the modal based on some requeriment at the moment of the save. Something like "Hey there's no stock, pick up one of the following options to continue (discard, reserve...) and press that button (that may do a postback for continue)"

我正在使用 ASP.NET 网络表单.

I'm using ASP.NET web forms.

推荐答案

最后我发现了阻止我从代码隐藏显示模式的问题.人们一定认为这就像注册一个打开的客户端脚本一样简单,比如:

Finally I found out the problem preventing me from showing the modal from code-behind. One must think that it was as easy as register a clientscript that made the opening, like:

ScriptManager.RegisterClientScriptBlock(this, this.GetType(),"none",
    "<script>$('#mymodal').modal('show');</script>", false);

但这对我没有用.

问题在于,当模式位于 asp:Updatepanel 中时,Twitter Bootstrap Modals 脚本根本不起作用.模态的行为从每一方都失败,代码隐藏到客户端和客户端到代码隐藏(回发).当模态的任何 js 已执行时,它甚至可以防止回发,例如关闭按钮,您还需要处理一些服务器对象(对于一个肮脏的例子)

The problem is that Twitter Bootstrap Modals scripts don't work at all when the modal is inside an asp:Updatepanel, period. The behaviour of the modals fail from each side, codebehind to client and client to codebehind (postback). It even prevents postbacks when any js of the modal has executed, like a close button that you also need to do some sever objects disposing (for a dirty example)

我已经通知了引导人员,但他们回复了一个方便的回答请给我们一个只有纯 html 而不是 asp 的失败场景."在我的城镇,这被称为......好吧,Bootstrap 不支持任何比普通 html 更多的东西.没关系,在asp上使用它.

I've notified the bootstrap staff, but they replied a convenient "please give us a fail scenario with only plain html and not asp." In my town, that's called... well, Bootstrap not supporting anything more that plain html. Nevermind, using it on asp.

我认为他们至少要看看他们在背景管理方面的不同之处,我发现这是导致问题的主要部分,但是......(只是提示)

I thought them to at least looking what they're doing different at the backdrop management, that I found causes the major part of the problems, but... (justa hint there)

所以任何有问题的人,放下更新面板试一试.

So anyone that has the problem, drop the updatepanel for a try.

这篇关于从代码隐藏打开引导模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆