Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Wednesday, March 28, 2012

UpdateProgress render inline option?

UpdateProgress always seems to render the contents of <ProgressTemplate> on a new line. Any simple way to have that render inline where it is placed?

You can to do this using css styles.

<styletype="text/css">
#updateProgress1
{
display:inline;
}
</style>

Make sure that the ID of your progress control is updateProgress1.

I could see that working except that the ID of my Progress control gets some extra naming container ID's attached to it. Not being a CSS master I wonder if it were wrapped with another DIV that displayed inline shouldn't that take care of it?


Yes you can do something like that.

<div id="enclosure">
<atlas:updateprogress ... >
</div>

You can use selector as follows

#enclosure div
{
display: inline;
}


The above suggestion doesn't seem to work - as the UpdateProgress DIV is styled inline (varying between "display:none" and "display:block") - the inline "display:block" overrides the stylesheet setting.

Best soultion I could come up with was to use the following code:

<p><span class="progress"> <atlas:UpdateProgress ID="updateProgress" runat="server"> <ProgressTemplate> <img id="Img1" runat="server" src="~/Images/Progress.gif" /> Updating... </ProgressTemplate></atlas:UpdateProgress></span><asp:Button ID="testButton" runat="server" Text="Refresh" /></p>  
span.progress{ position: absoulte; left:100px;}

Using,position:absolute will take the 'progress' span out of the document flow, thus not affecting other page elements. Setting just the "left" position will move the image across from the button (which is less than 100 pxels wide)

This is by no means elegant, but achieves a goal. (and it assumes you have spare space to the left of your update button).

Other variations on this soultion could place the update indicator at the top left/right of the screen - (something like gmail does)

Would be much better if the UpdateProgress control could rendereither as a Block or Inline element!

Alternatively to all of this, you could wrap the button and Progess control in a 2 cell table...


It would be good if a RenderMode property could be added to UpdateProgress in the same way as the UpdatePanel.

The RenderMode property can be either Inline or Block, and that causes it to either output a wrapper <span> or <div> accordingly.

Just seems that the UpdateProgress is missing that property (not in July 2006 CTP anyway)

Daniel.


Actually I have just tried enclosing the UpdateProgress with a span as so:-

<span class="progress"> <atlas:UpdateProgress runat="server" ID="up1"> <ProgressTemplate> <asp:Image ID="Image1" runat="server" ImageUrl="~/images/wait.gif" /> </ProgressTemplate> </atlas:UpdateProgress></span>
 and used
span.progress div{display: inline;}
 
which works fine (July CTP).

I have it working without the inline, a float: left; did the trick.

span.progress div
{
float:left;
}

Wednesday, March 21, 2012

UrlRewrites and CascadingDropdown

I had forgotten that my framework re-writes paths using urlrewrite - it works that well ;)

Anyway, I have narrowed the problem down to this line in Page_Load to fix postbacks
Context.RewritePath(Path.GetFileName(Request.RawUrl));

This causes the service to stop working even if I specify the "real"path to the service using "~/path/subpath/service.asmx" syntax.
Neither does the "page" method work (not specifying a ServicePath)

My question: how to get the CascadingDropdown to work with RewritePath?Why is it necessary to rewrite the path of the web service?
I am not rewriting the URL of the webservice - how would you do that without some complex handler? =)

The problem seems to be that the CascadingDropdown is on a page that has the url rewritten, or more specifically, rewritten at page_load.
I'm not familiar with URL rewriting, but I think I see how that might break a page method (ServiceMethod blank, ServicePath set). However, I'd expect a web service call (ServiceMethod set, ServicePath set) to continue to work as long as the web service URL didn't change. Do I understand that that scenario isn't working for you either? Does it work if you disable the URL rewriting? Would it be possible to post a simple page demonstrating the problem?
In attempting to create a "simple" test I discovered that requests to webservices do not like path info appended to it at all - I was using that instead of querystrings as I only had a single "branch" parameter.

Anyway, after cleaning up the code to only append path info for .aspx pages, the service worked as expected.

Thanks
For anyone interested, here is the code I used to test this

Create urlReWriteTest.cs in App_Code:

using System;
using System.Web;

namespace QuoteEngine.Utils.Branding
{
public class urlReWriteTest
{
public static void Process()
{
Uri url = HttpContext.Current.Request.Url;
string branch;
/* a request is of the form:
* /<applicationpath>/<branch>/<rest of request>
* we map this to:
* /<applicationpath>/Engine/<rest of request>
*/if (url.Segments.Length > 3)
{
//get branch (first segment is "/", then application path, then "branch") branch = url.Segments[2].TrimEnd("/".ToCharArray());
string rest ="";
for (int i = 3; i < url.Segments.Length; i++)
{
rest += url.Segments[i];
}
if (HttpContext.Current.Request.Path.ToLower().EndsWith(".aspx")) {
HttpContext.Current.RewritePath(HttpContext.Current.Request.ApplicationPath +"/Engine/" + rest, branch, HttpContext.Current.Request.QueryString.ToString());
}else {
HttpContext.Current.RewritePath(HttpContext.Current.Request.ApplicationPath +"/Engine/" + rest,"", HttpContext.Current.Request.QueryString.ToString());
}
}

}
}
}

In Global.asax, add:

void Application_BeginRequest(object sender, EventArgs e) {
urlReWriteTest.Process();
}
A page needs:

protected void Page_Load(object sender, EventArgs e) {
Context.RewritePath(Path.GetFileName(Request.RawUrl));
}
So that the postbacks go to the right place.

You can then check the branch using either:

//take the path, split by /, what differs is our branchstring[] raw = Request.RawUrl.ToLower().Replace(Request.Url.Query,"").Split("/".ToCharArray());
string[] path = Request.Path.ToLower().Split("/".ToCharArray());
string branch =null;
for (int i = 0; i < path.Length; i++) {
if (raw[i] != path[i]) {
branch = raw[i];
break;
}
}
or
string branch = Request.PathInfo;
As only .aspx will have the PathInfo

Good luck and all thatBig Smile
Yes, I now learnt that all requests get rewritten, not just page request :P