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

Wednesday, March 28, 2012

changes to adding ScriptReference?

Greetings! I have a javascript file that does some rounded corners on my page called rounded.js. In Beta1 I declared it like this

<asp:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Path="~\rounded.js" /> </Scripts></asp:ScriptManager>

This is inside my Master Page. After the content place holders, at the end of the master page I have this.

<script type="text/javascript"> Rounded('header',6,6); Rounded('navigation',6,6); Rounded('content',10,10); Rounded('navigationright',6,6); Rounded('footer', 6, 6); </script>

It worked great with Beta1 but doesn't in Beta2. There are no rounded corners, and the javascript error reads:

Sys.ScriptLoadFailedException: The script 'rounded.js' could not be loaded or does not contain the Sys.Application.notifyScriptLoaded() callback.

Now, if I navigate with the back and forward buttons to pages inside my app, I still get the error, but the script does load somehow, because the rounded corners are there.

Please help!

Check out the release notes for the ASP.NET AJAX Extenstions (C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\ReleaseNotes.txt)...

Under "4.3: Client Framework" you will see some notes about "* Script loading improvements". Relevant to your situation: "Component developers and page developers creating file-based script libraries that are registered with the ScriptManager control should include a JavaScript code snippet that indicates that the library has been downloaded by the client. Although this is not required in all browsers, Safari requires this to be able to dynamically load scripts."

Try adding this line to the very end of your 'rounded.js' file:

if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

Thanks,
Kyle


Is the CTP libraries also need this change?

I use this code to reference CTP libraries:

1<asp:ScriptManager ID="ScriptManager1" runat="server" >2<Scripts>3<asp:ScriptReference Path="~/PreviewDragDrop.js" />4<asp:ScriptReference Path="~/PreviewGlitz.js" />5<asp:ScriptReference Path="~/PreviewScript.js" />6</Scripts>7</asp:ScriptManager>
is it right? I copied these files to my site's root directory.
and I also got the "script could not loaded" exception while running...

hello.

well, i think the value added bits don't notify the sys.application object on completion of the load. so, you can add that line to the files or you can add them to the page through the <script> element.


hey all

im having the same problem now ive upgraded :-(

The solution was to add the following line:

if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

Im still getting the same error being thrown though :-( My JS file looks like this:

function

test()
{
alert("function called");
}
if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

and i call the script like this:

<

Scripts>
<asp:ScriptReferencePath="JScipt.js"/>
</Scripts>

What am i doing wrong??

Cheers Will


hello,

make sure IE is not caching the js file.


hey - thanks for the quick reply!

Yeh i just tried clearing out all the IE cache, but its still moaning :-(

What else could i be doing wrong?


hello.try debugging the page and make sure that the call to notifyscriptloaded is being made.

ok im getting somewhere!

i tried changing the script path on my test project to an absolute path

before: Path="JScript.js"

after: Path="http://localhost:2303/AjaxControlToolkitWebSite1/JScript2.js"

all works fine! this is not summet i want to do, so why is not looking in the wrong place?

Cheers for ya help dude

Will


hello.

i've been having some problems with the internal server, ie, i'm having several issues with the caching of files when i use the internal server.


I am having the exact same problem with the internal server caching files...did you figure out a good work around?

Thanks, Greg Benoit


hello.

wll, not really. i've started using IIS :)


What are the steps for converting an existing file based project to using IIS?? I tried and almost got it working, but when I went to login using my login control and the aspnetdb the login control reported back that my login credentials were incorrect??

Thanks, Greg

Change datasource for a datagrid using ajax

Hi ppl,

I have a datagrid with XML's as a source file. I have a combo box in the same page and when a user selects a value from the combo box i want to display different stats data without doing a normal postback. I am still learning the updatepanel Ajax control . Can anyone please guide me what i should i do to achieve the functionality? do i need to write any function in js ?

Any help much appreciated

thanks

Place the UpdatePanel around the DataGrid and the Combobox. Make sure the combobox do a postback, set the Autopostback attribute to true. Hook up to the OnSelectedIndexChanged event and get the data based on the selected value and bind it to the DataGrid. When a control inside a UpdatePanel will do a postback, the content of the UpdatePanel will be updated.

If you layout of you page don't allow a UpdatePanel around your combobox, you can instead add a async. postback trigger to the UpdatePanel that will listen to a control's event and update the panel.


Hi Thanks for the response. I placed as the gridview control in the updatepanel and used async trigger as you mentioned. when i changed the dropdownlist the grid doesnt appear at all.

Here is the script and code:

<

divID="Panel1"style="width: 568px; position: static; height: 180px; background-image: url(images/bg-nav.png);">

<spanstyle="color: #ffffff"><strong>

Select L :

</strong></span><asp:DropDownListID="DropDownList1"runat="server"Width="134px"AutoPostBack="True"OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1"><asp:ListItemSelected="True"Value="1">yes</asp:ListItem><asp:ListItemValue="2">no</asp:ListItem></asp:DropDownList><br/><asp:UpdateProgressID="UpdateProgress1"runat="server"AssociatedUpdatePanelID="test"><ProgressTemplate><divstyle="color: #ffffff; background-color: transparent"><imgsrc="images/indicator.gif"/>

Updating ....

</div></ProgressTemplate></asp:UpdateProgress><asp:UpdatePanelID="test"runat="server"><ContentTemplate><asp:GridViewID="GridView1"runat="server"ForeColor="Silver"BorderColor="LimeGreen"BorderStyle="Inset"AutoGenerateColumns="True"><AlternatingRowStyleBackColor="LightSkyBlue"ForeColor="#404040"/></asp:GridView></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropDownList1"EventName="SelectedIndexChanged"/></Triggers></asp:UpdatePanel>

Code:

ProtectedSub DropDownList1_SelectedIndexChanged1(ByVal senderAsObject,ByVal eAs System.EventArgs)If DropDownList1.SelectedValue = 1ThenDim myDataSetAsNew DataSet()

myDataSet.ReadXml(Server.MapPath(

"test1.xml"))

GridView1.DataSource = myDataSet

GridView1.DataBind()

ElseDim myDataSetAsNew DataSet()

myDataSet.ReadXml(Server.MapPath(

"test2.xml"))

GridView1.DataSource = myDataSet

GridView1.DataBind()

EndIf

EndSub

When i give wrong XML File name, it comes up with the message saying that it cant find the xml file. Is it something i missing in grid control?

Any help much appreciated?


I copied your code, created 2 example XML files, and everything worked fine for me. When I select a value the GirdView was displayed with the correct XML file.

Hi Fredreik

Can you post your sample XML files? I tried using without AJAX functionality and its working fine :(

thanks


I can't think it has anything to do with your XML files, btw do you use the ASP.Net Ajax version 1.0 RTM, becuase your code runs on my machine with no problems at all so I can't see why it shouldn't work on yours.. maybe you have some more code that I don't have.. I only copy the code you posted.. mabye you do something in code-behind etc..!?

Saturday, March 24, 2012

CascadingDropDown within an Accordion

I have a functioning CDD that I add dynamically to the page during ON_LOAD. I also have a new Accordion that I declare in the ASCX file. Both of these work fine until I try to put the CDD inside the Accordion. I get the following error:

Couldn't get extender properties on extender . Make sure the ID is spelled correctly and the control is on the page.

With the CDD inside the Accordion, I find the dropdown id using:

tempControl = MyAccordion.FindControl("ddlClientCompany")

item1.TargetControlID = tempControl.UniqueID

When I step thru the code with VS I can see that the control is found and an ID is passed in. But an error is thrown:o my question is: 1) is this a bug? 2) What is the correct procedure to include a CDD within the Accordion?

Here is my full code for when I add the CDD (this works fine outside of the Accordion)...

Dim tempExtenderAs AtlasControlToolkit.CascadingDropDown =New AtlasControlToolkit.CascadingDropDown()

Dim item1As AtlasControlToolkit.CascadingDropDownProperties =New AtlasControlToolkit.CascadingDropDownProperties()

item1.Category ="clientCompanyID"

If item1.Category =""Then item1.Category ="none"

item1.DefaultCompany = bu.default_company_id

item1.PromptText ="-- Select Company --"

item1.ServiceMethod ="GetClientCompanies"

item1.ServicePath ="~/buService.asmx"

Dim tempControlAs DropDownList

tempControl = MyAccordion.FindControl("ddlClientCompany")

item1.TargetControlID = tempControl.UniqueID

tempExtender.TargetProperties.Add(item1)

I'll defer to Ted as Accordion expert, but I'm thinking you don't want UniqueID in "item1.TargetControlID = tempControl.UniqueID". I'd try just ID instead.

Thanks for your reply David,

First let me say that I think Atlas rocks and and glad to be part of the CTP, pain and all. Secondly, I am very excited about how Atlas has effect my application interface design- cool ideas with low overhead to implement...nice job!

I did try some combinations that included the ID instead of the UniqueID...but they didnt work.

Although I never got it to work by adding the Extender dynamically, I was able to get it to work when I fully declared the CDD within the ASCX page. This is a work around in my mind and would be very interested in finding out how to do this properly dynamically.

I am also unable to get the SELECTED_VALUE of the CDD from within the Accordion. I am forced to just parse the query object like so.

' lets try to checkout the form values manually

Dim tempDDLClientCompanyAs DropDownList = MyAccordion.FindControl("ddlClientCompany")

Dim tempDDLClientNameAs DropDownList = MyAccordion.FindControl("ddlClientName")

' This is still not returning a value

'client_name = sec.ScrubData(tempDDLClientCompany.SelectedValue)

'manager_name = sec.ScrubData(tempDDLClientName.SelectedValue)

Dim tempClientCompanyID = tempDDLClientCompany.UniqueID

Dim tempClientNameID = tempDDLClientName.UniqueID

Try

Dim formsCountAsInteger = (Request.Form.Count) - 1

If formsCount <= 0ThenExitTry

Dim countAsInteger = 0

' 1) Grab the values from the request for company and client name

Dim tempField, tempValueAsString

' This is not zero based because the forms collection is not zero based.

For count = 1To formsCount

tempValue =CType(Request.Form.Item(count),String)

tempField =CType(Request.Form.GetKey(count),String)

If tempField = tempClientCompanyIDThen

client_name = tempValue

EndIf

If tempField = tempClientNameIDThen

manager_name = tempValue

EndIf

Next

Catch exAs Exception

EndTry


Hi Matthew,

Are you adding the extender right next to the drop down? If they're in different naming containers than that might explain why it can't find it (i.e. even though you pass in UniqueID, it still wouldn't be able to find a match if it was only looking in its own naming container).

Thanks,
Ted


Thanks for the reply Ted,

Let me try to recall that issue...it was a day or so ago and I have since gotten my head around other items, but I believe I tried several places for the extender. 1) Outside the Accordion, and 2) inside the Accordion within the same pane as the CDD if that is what you mean. I'll pull the code tomorrow and see where I left off. cheers,

Wednesday, March 21, 2012

CascadingDropDown options not showing.

I have 2 dropdown boxes with the CascadingDropDown ajax extension attached to them, they are reading from an xml file not database. I dont get an error but my first dropdown bar shows "Please select an option" ie my prompt text, but not the xml options... my xml is set out correctly (ie the same hierarchical XML layout as the sample ajax website). Any ideas why this isnt showing me options but doesnt error? thanks in advance John

i feel as though i should explain more. Basically ive got an xml file layed out like :

<?xml version="1.0" encoding="utf-8" ?>
<GroupService>
<Group name="One">
<SubGroup name="One" />
<SubGroup name="Two" />
</Group>
</Service>

Based on two categorys. I have two drop down boxes with the code :

<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
Category="Group" PromptText="Please select a Type" LoadingText="[Loading makes...]"
ServicePath="GroupsService.asmx" ServiceMethod="GetDropDownContents" /
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2"
Category="SubGroup" PromptText="Please select a Group Type" LoadingText="[Loading models...]"
ServiceMethod="GroupsService.asmx" ParentControlID="DropDownList1" /
The ServiceMethod is correctly referance.Now my webservice is :

using System;
using System.Web;
using System.Collections;
using System.Collections.Specialized;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;

/// <summary>
/// Summary description for GroupsService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class GroupsService : System.Web.Services.WebService
{
// Member variables
private static XmlDocument _document;
private static object _lock = new object();

// we make these public statics just so we can call them from externally for the
// page method call
public static XmlDocument Document
{
get
{
lock (_lock)
{
if (_document == null)
{
// Read XML data from disk
_document = new XmlDocument();
_document.Load(HttpContext.Current.Server.MapPath("~/App_Data/GroupsService.xml"));
}
}
return _document;
}
}

public static string[] Hierarchy
{
get { return new string[] {"Group", "SubGroup" }; }
}

public GroupsService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
{
// Get a dictionary of known category/value pairs
StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

// Perform a simple query against the data document
return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category);
}

}

It doesnt give me an error and it says its loading but then no items are shown, has anyone else had this error? thanks in advance John


did a little bit of work on this and saw in the sample website i got with the ajax download the hierarchy is :

public static string[] Hierarchy
{
get { return new string[] { "make", "model" }; }
}

it misses out the last value ie color of the colours. so i change mine to :

public static string[] Hierarchy
{
get { return new string[] { "Group" }; }
}

ie got rid of the last valuein the hierarchy, but still no luck, does anyone know if it is possible to do this from 2 dropdown boxes rather than 3? if so can someone point me in the right direction? thanks in advance John


Hi,

Please refer to thisthread for how to use a XML document with different format.

Or you can change attribute "name" to "value" .


I have had the same issue all day.. Finally noticing the only difference between mine and the sample was case, I tried making the xml attribute strings names lower case ie.. <group> <subgroup> and made sure the heirarchy property was also lower case and they now populate.

Hope this helps

CascadingDropDown Hierarchy

Hi,
I've been playing around with the example from the toolkitand am wondering if its possible to replace the .xml file it uses to set theHierarchy with pointers to a dataset? I have no idea how to go about this! Anyhelp would bee really appreciated

Cheers,
Denis

Hi Denis -

Take a look athttp://blogs.msdn.com/sburke/archive/2006/04/14/576421.aspx


Thats exactly what I was after! Cheers
Glad to help!