Showing posts with label run. Show all posts
Showing posts with label run. Show all posts

Monday, March 26, 2012

Explaining the structure of Rating/Accordian Control

Are there any documentation or could anyonoe take the time to explain/document, or a step by step run through of creating controls similar to these two? Where the extender is 'dynamically' attached to a server control in the code?

Thanks and Regards.

Hi Inventisity,

Accordion,NoBot,Rating, andReorderList are all examples of controls that wrap extenders. This pattern is useful in situations where the extender requires the markup of the target control to be in a specific (and possibly lengthy) format. You write the server-side extender and client-side behavior as usual. You then create a control (by inheriting from something likeWebControl orPanel) that renders the appropriately formatted markup, dynamically create your extender/properties, and point yourproperties.TargetControlID atthis.ID (and hence the rendered markup). Following common practices for writing server controls, the extender and its properties are created in theCreateChildControls method (which we make sure is called before anywhere we access the extender/properties usingEnsureChildControls). Finally, the necessary properties are exposed on the control (and just passed off to the actual properties object).

I think this should give you an idea of what these controls are doing, but please post back if you have any other unanswered questions. If you plan on writing your own control that wraps extenders, keep an eye onwork item #1687 because it applies to all of these controls.

Thanks,
Ted

Execution of Atlas initialization phase

Is there a way to let the init phase of atlas run earlier than when *all* content of a page has been downloaded?

On our site we have content (images, iframes) from other sites. It seems the init phase will not run before all content (thus also content from out of our site, but also our own images) is downloaded. Which gives the user the illusion that our site is slow, but thats not the case, of course ... ;)

Thanks.

hello.

hum...i guess that you'll only have this problem if you're using xml-script. currently, i think that it only is processed on the window.load event...


Any news on this? Will atlas be able to runs its init phase earlier than the window.load event?

I am planning to call the Sys.Runtime.Initialize myself at the end of the HTML instead waiting for the window.onload event to eventually call it.

Does anyone see a downside for this?


I had the same idea, the problem is even when u place the code at the end of the document and call init() yourself u can't ensure that all scripts have been loaded. For example the following script block causes normally an exception saying the WebService.Method isn't aviable.

<script type="text/javascript"> Sys.Runtime.initialize(); WebService.Method( CallBack );</script>
Is there anyway to know when all (webservice)references are loaded and ready? I need to call a function before the window onload but after all atlas ref's are fully loaded.

What we did was doing *all* javascripts include ourselves.
We do not use the scriptreferences of atlas anymore. We even dont let atlas include his own js files...

With Page.ClientScript.RegisterClientScriptInclude we include the atlas.js and his friends. ;)
The services are included as "xxxservice.asmx/js".
This way *all* javascript files are included at the very top of the HTML,
then its save call the service like you were intended to.
The reason why we also register atlas js files is about the order of the include file in the HTML.
When we dont do it ourselfs, the atlas.js may be included to late in the HTML.

HTH

Yesterday I was thinking to mail the atlas team about this "self registerclientscriptinclude" instead of using the scriptreferences
for the very purpose you are describing. Now seeing your post I will definately mail them today! :)


Qty:

The services are included as "xxxservice.asmx/js"

I tryed this myself but i ended up getting requests like "/undefined?mn=MehodName" - i think this has something to do with the appPath var?


Perhaps you can include script that set the path & apppath

RegisterStartupScript "XXXService.path = 'http://website/XXXService.asmx'; XXXService.appPath = 'http://website/'"

HTH


Didn't know the .path var - thx a lot!

execute javascript after updatepanel

I am using this to run a function after an updatepanel, which works fine.

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(scroll_models);

Is is possible to build a function during the updatepanel update and then run it?

Please let me know.

apu808:

I am using this to run a function after an updatepanel, which works fine.

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(scroll_models);

Is is possible to build a function during the updatepanel update and then run it?

Please let me know.

Hi.

here you can see all the Events of PageRequestManager .Link , the look at pageLoaded event may that you need.

Regards.


I think you have to use

Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler)

See the link for details

http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerPageLoadingEvent.aspx


I was trying to do something fairly similar and what I ended up doing may be a hack to some, but I love the power of it. It is a User Control that on Page_Load creates javascript, and contains a boolean value that is available from the client and server to let the client know when to run the script.

This allowed me to always have the script loaded in the startup and it cheks the boolean before performing the other script. I was having trouble with multiple Update Panels and all of them needing to be able to update and call the same Javascript, but modify on the postback of the Update Panels and this allowed for that.

Saturday, March 24, 2012

Example of an Atlas Site

Well, I have been using some of the Atlas functionality now for quite a while and have used it to rewrite a site I run for charity.

I must admit, I have been pretty amazed with what you can do with it and the speed which you can develop something new. Thought I would post up my site so people could get ideas and give me suggestions on how it can be improved. Still putting the finishing touches on it.

http://www.scigoalplanning.com/ExerciseSearch.aspx

I am thinking about using the new animation functionality to provide a training demo to teach people how to use the website, as it can be a bit daunting for first time users.

This site is a resource of exercises for people who have suffered a spinal cord injury or like neurological condition. You can perform a search, get a gallery of exercises, choose exercises by clicking on the image and then make up an exercise booklet. You can create your own logons and then customise these booklets for clients and export them to word/PDF etc. It is meant to be used by physiotherapists.

Technical Background :

ASP NET 2, C# - Uses Atlas and Webservices extensively, Atlas Client Library - popups etc, SQL Server database

Super cool Atlas website

Wednesday, March 21, 2012

Error25Could not load file or assembly Microsoft.Web.Extensions, Version=1.0.61025.0, Cult

Hi there,

I am just trying to learn AJAX at the moment and have run into a problem. I have copied over the example for cascading dropdowns and this is where I have the above error.
The error occurs in the web.config file on this line

<

addassembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Can anyone advise what I need to change?

The sample is for old ajax version.

you need to copy latest ASP.NET AJAX web.config to your projects web.config

below is my cascading code for new version for you

ASPX

<%@. Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="CascadingDropDownDemo._Default" EnableEventValidation="false" %>

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="sm" runat="server">
</asp:ScriptManager>
<div>

<asp:UpdatePanel ID="upMain" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddl1" runat="server" Width="275px">
</asp:DropDownList><br />
<asp:DropDownList ID="ddl2" runat="server" Width="275px">
</asp:DropDownList><br />
<asp:DropDownList ID="ddl3" runat="server" Width="275px">
</asp:DropDownList><br />
<cc1:CascadingDropDown ID="ccd1" runat="server" TargetControlID="ddl1" Category="Make"
PromptText="Please select a make" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="ccd2" runat="server" TargetControlID="ddl2" Category="Model"
PromptText="Please select a model" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents"
ParentControlID="ddl1">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="ccd3" runat="server" TargetControlID="ddl3" Category="Color"
PromptText="Please select a color" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents"
ParentControlID="ddl2">
</cc1:CascadingDropDown>
<asp:Button ID="btnClick" runat="server" Text="I want this car." Width="282px" OnClick="btnClick_Click" /><br />
<br />
<asp:Label ID="lblInformation" runat="server" Text="[ No sellection made yet. ]"
Width="279px"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel> </div>
</form>
</body>
</html>

Code Behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace CascadingDropDownDemo
{
public partial class _Default : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnClick_Click(object sender, EventArgs e)
{
// Get selected values
string make = ddl1.SelectedItem.Text;
string model = ddl2.SelectedItem.Text;
string color = ddl3.SelectedItem.Text;

// Output result string based on which values are specified
if (string.IsNullOrEmpty(make))
{
lblInformation.Text = "Please select a make.";
}
else if (string.IsNullOrEmpty(model))
{
lblInformation.Text = "Please select a model.";
}
else if (string.IsNullOrEmpty(color))
{
lblInformation.Text = "Please select a color.";
}
else
{
lblInformation.Text = string.Format("You have chosen a {0} {1} {2}. Nice car!", color, make, model);
}
}

[WebMethod]
[System.Web.Script.Services.ScriptMethod()]
public static AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContentsPageMethod(string knownCategoryValues, string Category)
{
CarsService cs = new CarsService();
return cs.GetDropDownContents(knownCategoryValues, Category);
}

protected void ddl3_SelectedIndexChanged(object sender, EventArgs e)
{
string make = ddl1.SelectedItem.Text;
string model = ddl2.SelectedItem.Text;
string color = ddl3.SelectedItem.Text;

// Output result string based on which values are specified
if (string.IsNullOrEmpty(make))
{
lblInformation.Text = "Please select a make.";
}
else if (string.IsNullOrEmpty(model))
{
lblInformation.Text = "Please select a model.";
}
else if (string.IsNullOrEmpty(color))
{
lblInformation.Text = "Please select a color.";
}
else
{
lblInformation.Text = string.Format("You have chosen a {0} {1} {2}. Nice car!", color, make, model);
}
}
}
}

web services code

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

using AjaxControlToolkit.Design;
namespace CascadingDropDownDemo
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CarsService : 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("~/CarsService.xml"));
}
}
return _document;
}
}

public static string[] Hierarchy
{
get
{

return new string[] { "make", "model" };
}
}

/// <summary>
/// Constructor to initialize members
/// </summary>
public CarsService()
{
}


/// <summary>
/// Helper web service method
/// </summary>
/// <param name="knownCategoryValues">private storage format string</param>
/// <param name="category">category of DropDownList to populate</param>
/// <returns>list of content items</returns>
[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);
}
}

}

Good luck


Hi MIB426,

Thanks heaps for your code...I am pretty new to both .NET & AJAX so I need to be a pain and ask a couple more questions.

Where can I get the web.config file from?

This part of your code (web services code) where am I meant to add this to?

Thanks heaps for your help!

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

using AjaxControlToolkit.Design;
namespace CascadingDropDownDemo
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CarsService : 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("~/CarsService.xml"));
}
}
return _document;
}
}

public static string[] Hierarchy
{
get
{

return new string[] { "make", "model" };
}
}

/// <summary>
/// Constructor to initialize members
/// </summary>
public CarsService()
{
}


/// <summary>
/// Helper web service method
/// </summary>
/// <param name="knownCategoryValues">private storage format string</param>
/// <param name="category">category of DropDownList to populate</param>
/// <returns>list of content items</returns>
[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);
}
}

}


Sorry its me again.

Ok I have created a new page called default2.aspx and added the above code. I created a new web service "WebService" and added the above code into WebService.cs.

When I try run the the form I get an error saying "Error 29 Could not create type 'WebService'. C:\Users\shane\Desktop\AJAXEnabledWebSite4\WebService.asmx 1"

What else do I need to change.....Please help!!!!!!!

Thank you

Error1Could not load file or assembly Microsoft.Web.Preview or one of its dependencies. Th

Trying to run the samples and this is the error I get. After looking around I see others have gotten this error but with the beta versions.

My install is not a beta release and I have not had any of the betas installed.

Any ideas?

I would look to your web config file or possibly your machine config file. Im betting you somehow got some old beta settings in it. possibly do a search for Microsoft.Web.Preview in your entire solution.

AjaxButter


The other thing i just noticed is you said you were running the samples. Im betting your using an old compilation of the sample files that was meant to use the beta version redownload the sample your using and give it another go.

Sorry for the double post

AjaxButter


Hi,

If you have installed the AJAX Extensions 1.0, the assembly Microsoft.Web.Preview not exists.

You must to replace all the references and assemblies in the samples for run this.

Hope this helps


Replace with what?

How the Microsoft.Web.Preview not exists with the AJAX extension 1.0, you must to work with the System.Web.Extensions assembly and System.Web.Extensions.Design assembly, installed in the Microsoft ASP.NET folder in Program Files folder.

Replace the web.config with the web.config that is generated in a new ASP.NET AJAX Enabled Web Site.

Or replace your web.config with the web.config file that is in the Microsoft ASP.NET folder.



From InstallationInstructions.txt:

Completing the Installation
--------
After downloading and uncompressing the sample files, copy Microsoft.Web.Preview.dll from the
ASP.NET AJAX CTP installation directory (%Program Files%\Microsoft ASP.NET\ASP.NET 2.0 AJAX
Futures January CTP\v1.0.61025\) to the Bin directory of each sample application. For example,
copy Microsoft.Web.Preview.dll to <installation path>\Contacts\Bin, where <installation path>
is the file path where the ASP.NET AJAX Samples were installed.

You must also copy AjaxControlToolkit.dll from the AJAX Control Toolkit directory to the Bin
directory of each sample application. For example, copy <toolkit installation path>
\AjaxControlToolkit\SampleWebSite\Bin\AjaxControlToolkit.dll to <installation path>\Contacts\Bin,
where <toolkit installation path> is the installation path for the AJAX Control Toolkit and
<installation path> is the file path where the ASP.NET AJAX Samples were installed.

Earlier in InstallationInstructions.txt are the download locations for the Futures CTP and the Control Toolkit.