PDA

View Full Version : Ext.Coolite.ThisUrl



Timothy
Sep 05, 2008, 11:03 AM
Hello,

Can we get a new optional property added to the Ext:ScriptManager to override the default generation of the Ext.Coolite.ThisUrl appended to the client script?  You are currently setting the value to the result of HttpContext.Current.Request.Url but this does not work welll when you have a URL rewriter in the way :)


Example:




public void Page_Load(object sender, EventArgs e)
{
    ScriptManager.ThisUrl = "http://www.google.com";
}





Cheers,
Timothy

Vladimir
Sep 05, 2008, 11:33 AM
Hi Timothy,
How do you want to use the ThisUrl? Now the ThisUrl is used only if no form on Page. Do you have such pages or you want to use ThisUrl in own custom javascript code?

Timothy
Sep 05, 2008, 11:45 AM
Hmm, from what I've seen Ext.Coolite.ThisUrl is always rendered regardless if a form is available or not.

I would just like to be able to have a property exposed on the Ext:ScriptManager so I can feed in my own URL rather than the default HttpContext.Current.Request.Url which is currently always getting generated -- it is not a URL rewrite safe value ;)

Thanks vladimir!

Cheers,
Timothy

davidhoyt
Oct 10, 2008, 9:55 PM
I second this request. I'm using URL rewriting to deliberately hide the aspx page. I can confirm that at least in 0.6.0, it's always written (irregardless if there's a form or not).

Timothy
Oct 11, 2008, 12:43 AM
Hello davidhoyt,

Use the following, make your page inherit from this class instead of System.Web.UI.Page



public class MyPage : System.Web.UI.Page
{
protected override void Render(HtmlTextWriter writer)
{
using (StringWriter temp = new StringWriter())
{
using (HtmlTextWriter buffer = new HtmlTextWriter(temp))
{
base.Render(buffer);

String result = temp.ToString();

string thisUrl = String.Format(@"{0}://{1}{2}",
Request.Url.Scheme,
Request.Url.Host,
Request.RawUrl);

result = Regex.Replace(result,
@"Coolite.Ext.ThisUrl='.*?';",
String.Format(@"Coolite.Ext.ThisUrl='{0}';",
thisUrl
)
);
writer.Write(result);
}
}
}
}


Cheers,
Timothy

Timothy
Oct 11, 2008, 12:44 AM
Let me know if you need any help with using url rewriting and Microsoft AJAX. I've got a good (simple solution) :)

Cheers,
Timothy

geoffrey.mcgill
Oct 11, 2008, 3:31 PM
I'm looking into a new solution for the ScriptManager.ThisUrl property. We will be making some changes. 

davidhoyt
Oct 11, 2008, 11:23 PM
Thanks for your solution, Timothy, but I wouldn't recommend doing that since it's buffering the entire page in memory before doing the search and replace. There are cases where it wouldn't work properly and I'm sure you can see why buffering a large page for every request could be problematic. The correct solution is for the Coolite folks to make it adjustable.

I suppose that begs the question - could you make that property themeable?

Timothy
Oct 13, 2008, 2:26 PM
My suggestion was only a work around until Coolite changes the functionality. If your page size is a major concern until they change the functionality, here are some suggestions:

1. Reduce the size of your page; if it's too large for your server to buffer it's going to be too large for your client to swallow

2. Use my suggestion to override the Page.Form control and override its internal rendering routines to focus the buffering specifically on the Form control

Timothy