Showing posts with label framework. Show all posts
Showing posts with label framework. Show all posts

Saturday, March 24, 2012

Upgrade to Beta 1 = New Rating control error

I installed the latest framework and toolkit.

My project was working fine with a wizard control that contained rating controls. I've taken the rating controls out of the wizard template and put them in their own update panel and still receive the error. It's a very strange behavior. If I make a new page and do everything, the rating control works fine. I'm using the latest control and did all the changes required to use the new Beta. After the install, I keep receiving this error when loading the page:

System.InvalidOperationException was unhandled by user code
Message="The TargetControlID of '_RatingExtender' is not valid. The value cannot be null or empty."
Source="Microsoft.Web.Extensions"
StackTrace:
at Microsoft.Web.UI.ExtenderControl.RegisterWithScriptManager()
at Microsoft.Web.UI.ExtenderControl.OnInit(EventArgs e)
at AjaxControlToolkit.ExtenderControlBase.OnInit(EventArgs e) in C:\Program Files\Microsoft ASP.NET\AjaxControlToolkit\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:line 338
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at Microsoft.Web.UI.UpdatePanel.SingleChildControlCollection.AddSingleChild(Control child)
at Microsoft.Web.UI.UpdatePanel.AddContentTemplateContainer()
at Microsoft.Web.UI.UpdatePanel.CreateContents(Boolean recreate)
at Microsoft.Web.UI.UpdatePanel.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Thanks

Anyone ? Can you please take a look? I believe others are experiencing something similar with the mentioned TargetControlID.

Thanks


When the project breaks, it breaks at the bold:

/// <summary>
/// On Init we load target properties values and process databinding handlers.
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
if (EnableClientState)
{
CreateClientStateField();
}
// EnsureProfileScriptService(ScriptManager.GetCurrent(Page), true);
Page.PreLoad += new EventHandler(Page_PreLoad);
base.OnInit(e);
}


Please reply with acomplete, self-contained sample page that demonstrates the problem. Thank you!

In my case the problem occures when I specify the rating control in the skin file.

Skinfile:

<

ajaxToolkit:Ratingrunat="server"StarCssClass="ratingStar"WaitingStarCssClass="savedRatingStar"FilledStarCssClass="filledRatingStar"EmptyStarCssClass="emptyRatingStar"/>
Good to know! Do you have a complete, self-contained sample we can play with?

Just add the following 2 lines in the Default.skin file of the Ajax Control Toolkit SampleWebSite:

<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>
<ajaxToolkit:Ratingrunat="server"StarCssClass="ratingStar"WaitingStarCssClass="savedRatingStar"FilledStarCssClass="filledRatingStar"EmptyStarCssClass="emptyRatingStar"/>

Then try to open the Rating sample of the SampleWebSite.


The SampleWebSite doesn't have a Default.skin file - might there be something else going on here that's causing issues?

Upgrading to CTP / ASP.net Ajax

hey guy,

finally i decided to upgrade my ajax framework to the most recent one and i notice some errors which i havn't recieve beofer the upgrade. can someone give a hand here? i really need to resolve those problems ASAP.

this first problem that i'm getting is document.body is null or not an object (the debugger stops in this line):

AjaxControlToolkit._CommonToolkitScripts = function() { /// /// The _CommonToolkitScripts class contains functionality utilized across a number /// of controls (but not universally) /// // Populate the borderThicknesses lookup table this._borderThicknesses = { }; var div0 = document.createElement('div'); var div1 = document.createElement('div'); div0.style.visibility = 'hidden'; div0.style.position = 'absolute'; div0.style.fontSize = '1px'; div1.style.height = '0px'; div1.style.overflow = 'hidden';document.body.appendChild(div0).appendChild(div1);

and the second one is commontoolscripts is null or not an object:

AjaxControlToolkit.ModalPopupBehavior.callBaseMethod(this, 'initialize'); this._foregroundElement = $get(this._PopupControlID); this._backgroundElement = document.createElement('div'); this._backgroundElement.style.display = 'none'; this._backgroundElement.style.position = 'absolute'; // Want zIndex to big enough that the background sits above everything else // CSS 2.1 defines no bounds for the type, so pick arbitrarily this._backgroundElement.style.zIndex = 10000; if (this._BackgroundCssClass) { this._backgroundElement.className = this._BackgroundCssClass; } this._foregroundElement.parentNode.appendChild(this._backgroundElement); this._foregroundElement.style.display = 'none'; this._foregroundElement.style.position = 'absolute'; this._foregroundElement.style.zIndex =CommonToolkitScripts.getCurrentStyle(this._backgroundElement, 'zIndex', this._backgroundElement.style.zIndex) + 1;

thanks,

ori

Did you move to AJAX RC ? Did you move from Beta 2 or CTP ? Use following document

CTP to RC

http://ajax.asp.net/files/Migration_Guide_CTP_to_RC.aspx

Beta 2 to RC

http://ajax.asp.net/files/Migration_Guide_Beta2_to_RC.aspx

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