asp:UpdateProgress-禁止换行
时间:2020-03-05 18:47:16 来源:igfitidea点击:
我已经开始使用ASP.net AJAX(最后是?)。我有一个更新面板和一个asp:UpdateProgress。我的问题:UpdateProgress始终强制换行,因为它呈现为div标签。
有什么办法可以代替它吗?我想将其与其他一些控件显示在同一行上,而不必使用表,甚至不必在CSS中进行绝对定位。
如果这有所作为,我会坚持使用ASP.net AJAX 1.0和.net 3.0。
解决方案
回答
我们可以像这样使div内联:
<div style="display:inline">stuff</div>
我对它是否为我们呈现div表示怀疑...我不记得我的页面上有这个问题...
回答
我有同样的问题。没有简单的方法告诉updateProgress内联呈现。我们最好推出自己的updateProgress元素。我们可以添加beginRequest侦听器和endRequest侦听器以显示和隐藏要内联显示的元素。这是显示如何执行此操作的简单页面:
aspx
<form id="form1" runat="server"> <div> <asp:ScriptManager ID="sm" runat="server"></asp:ScriptManager> <asp:UpdatePanel runat="server" ID="up1" UpdateMode="Always"> <ContentTemplate> <asp:Label ID="lblTest" runat="server"></asp:Label> <asp:Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_OnClick" /> </ContentTemplate> </asp:UpdatePanel> <img id="loadingImg" src="../../../images/loading.gif" style="display:none;"/><span>Some Inline text</span> <script> Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function(sender, args) { if (args.get_postBackElement().id == "btnTest") { document.getElementById("loadingImg").style.display = "inline"; } }); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(sender, args) { if (document.getElementById("loadingImg").style.display != "none") { document.getElementById("loadingImg").style.display = "none"; } }); </script> </div> </form>
CS
public partial class updateProgressTest : System.Web.UI.Page { protected void btnTest_OnClick(object sender, EventArgs e) { System.Threading.Thread.Sleep(1000); this.lblTest.Text = "I was changed on the server! Yay!"; } }
回答
只需将UpdateProgress放在具有style =" position:absolute;"的范围内即可。
回答
只需将float:left
应用于标签/文本框等。
像这样:
在标题中:
<style type="text/css"> .tbx { float:left; }
在身体里:
<asp:TextBox CssClass="tbx" .... />
回答
我只是在博客中介绍我自己针对此问题的解决方案。
http://www.joeaudette.com/solving-the-aspnet-updateprogress-div-problem.aspx
我所做的是从Mono项目借用UpdateProgress控件,并将其修改为呈现为跨度而不是div。我还复制了与控件关联的修改后的ms-ajax javascript,并将其修改为在display:inline和display:none之间切换,而不是使用display:block
我的帖子中链接了一个.zip文件,其中包含已修改的文件。