Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Monday, March 26, 2012

Duplicate Script Reference

I am trying to create a WebControl dll. There is a common.js file in the dll. It is shared bewteen all WebControls.

If I simply add the script reference using
ScriptManager.Scripts.Add( ...) or implementingGetScriptReferences function of IScriptControl. Duplicate script reference will be created when user add multiple web controls.

It is a problem because a ajax javascript class cannot be registered twice.

If I use ScriptManager.RegisterClientScriptInclude, the script will be unique but it is inserted before ajax javascript liberary.

It seems that I have to do something special to make this work. anyone has suggestions or has experienced the same issue??

thanks

Rushui

Look up the example under ajax.asp.net/docs for the IScriptControl interface. If you implement the interface using their example as a template you shouldn't have issues; I'm not sure what they're doing under the hood, but the GetScriptReferences method specified is being called in some way that helps avoid conflicts.

Upon further investigation, it seems that duplicate script reference of a web control dll can be avoided by implementing GetScriptReference function of IScriptControl interface. The Scripts collection of ScriptManager however doesnot check for duplicates.

My situation is a bit strange since I am trying to share a common js lib between the page and the web control dll. Guess I just have to avoid doing that.

Thanks

Rushui

Dummy read the FAQ and still needs help re: using JS to set expandedSize property of Colla

Really wish I wasn't this dense. I found the .js file and I read the FAQ -- there is no reason I should not know how to do this, but I keep getting JS errors.

I want to be able to size the expanded size of a Collapsible Panel based on the size of the client browser. Thus far, I have:

assigned BehaviorID="myCP" to the panel (id="Admit") on the server;

found the _expandedSize property in the AjaxControlToolkit.CollapsiblePanelBehavior constructor in the .js file

I guess I have never had to reference an instance of an object that I didn't create myself, so I have no idea how to change the property in the instance.

I thought $get("myCP")._expandedSize=500 would work, but nope.

Stumped and stupid. Thanks for taking the time to read this, and for any length you can add to my bus!

Hi Mrgr8avill,

Get/set the height property,

var height = $find("CollapsiblePanelExtender's BehaviorID").get_TargetHeight();

$find("CollapsiblePanelExtender's BehaviorID").set_TargetHeight(500);

Get/set the width property ,

var width = $find("CollapsiblePanelExtender's BehaviorID").get_TargetWidth();

$find("CollapsiblePanelExtender's BehaviorID").set_TargetWidth(500);

Best regards,

Jonathan

Wednesday, March 21, 2012

DropDownExtender throwing 404 "File does not exist" error

I have used DropDownExtender in my projects and it works fine. However if I check the HTTP log using Web Development Helper (fromwww.nikhilk.net), I find a 404 response as it tries to get a file/resource "null" from the current folder (e.g. SampleWebSite/DropDown/null). I can get the same "error" when I run the sample web site of AjaxControlToolkit. Is this a bug? Although it works fine even with the 404 response, it bothers me because my application does catch it and log it in the event log.

Hope someone can tell me how to get rid of the 404 response.

Thanks

Edwin

Hi Edwin,

This is the internal behavior of the DropDownExtender control. The request is sent by an image element( the dropdown image ).

Initially, the img element's src is set to null, thus the browser sends a request to currentRootFolder/null for it.

When you move the mouse over it, its src is changed to a valid image ( by default, a triangle ).

When a postback happens, the img element is reinitialized to null again.

That's why you will see a 404 response.

It's not encouraged to change the source code/internal behavior of the DropDownExtender to get rid of it, because inappropriate change may bring a bigger trouble.

How do you enable logging on your application? It will be better if you can apply a filter to it. For instance, don't log the one whose request contain a url like "folderName/null"

Hope this helps.


Hi Raymond

What you described is the function of the DropDownExtender but I believe the 404 response can be avoided rather than being a "normal" occurence. I have posted the issue on codeplex (http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=11521) and hope this may help those who encountered the same problem.

Edwin