2008-09-03 47 views
9

我已经开始使用ASP.net AJAX(最终☺)。我有一个更新面板和一个asp:UpdateProgress。我的问题:UpdateProgress总是强制换行,因为它呈现为div标签。asp:UpdateProgress - 遏制换行

有什么办法强制它成为一个跨度而不是?我想在一些其他控件的同一行上显示它,而不必使用表格,或者甚至在CSS中使用绝对定位颤抖。

我与ASP.net AJAX 1.0和.net 3.0卡住,如果这有所作为。

回答

2

我的博客上讲述我自己解决这个问题。 http://www.joeaudette.com/solving-the-aspnet-updateprogress-div-problem.aspx

我所做的是从Mono项目中借用UpdateProgress控件,并将其修改为以跨度而不是div来呈现。我还复制了与该控件关联的ms-ajax javascript,并将其修改为在display:inline和display:none之间切换,而不是使用display:block

在我的帖子中有一个链接.zip文件,其中包含修改的文件。

+0

酷,从单声道的东西在一个很好的主意! – 2009-11-09 17:59:28

+0

我改变了接受的答案(对不起史蒂文!),因为这种方法效果更好。我已将源发布到我的UpdateProgressEx控件:http://www.stum.de/2010/01/28/an-asp-net-ajax-updateprogress-that-c​​an-render-inline/ – 2010-01-28 02:04:12

-2

你可以让一个div内嵌这样的:

<div style="display:inline">stuff</div> 

我怀疑它虽然使你的股利......我不记得我的网页上有这个问题...

7

我有同样的问题。有没有简单的方法告诉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!"; 
    } 
} 
9

只需将您的UpdateProgress风格=“位置的跨度内:绝对的; “

+0

这个伟大的工程。您需要将DynamicLayout属性设置为false以使其发挥作用。 – oscilatingcretin 2013-03-04 14:09:46

0

只是适用float:left到标签/文本等 像这样:

在标题:

<style type="text/css"> 
.tbx 
{ 
    float:left; 
} 

在身:

<asp:TextBox CssClass="tbx" .... /> 
1

一个更好,最简单的方法是在UpdatePanel中使用带有span的UpdateProgress。我已经测试过这个功能,并在IE,FF和Chrome浏览器中正常工作。像这样:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
     .......... 
     <span style="position:absolute;"> 
      <asp:UpdateProgress ID="UpdateProgress1" runat="server" 
       AssociatedUpdatePanelID="UpdatePanel1"> 
        <ProgressTemplate> 
         <img alt="please wait..."src="/Images/progress-dots.gif" /> 
        </ProgressTemplate> 
      </asp:UpdateProgress> 
     </span> 
    </ContentTemplate> 
</asp:UpdatePanel> 
0

我的解决办法如下把它包起来......

<div class="load-inline">LOADER HERE</div> 

而在我的CSS我用...

.load-inline {display:inline-block} 
3

我的解决办法: 在CSS

.progress[style*="display: block;"] { 
    display:inline !important; 
} 

和ASP

<asp:UpdateProgress class="progress" ID="UpdateProgress1" runat="server">