Showing posts with label existing. Show all posts
Showing posts with label existing. Show all posts

Wednesday, March 28, 2012

Preferred Approach to Existing .Net Server Controls and Client Scripting

In asp.net 1.1, the mechanism I used on many occassions is to add attributes to work some client side script. ie. a .NET dropdownlist:

ddlMonOfficeStart.Attributes.Add("onChange",string.Format("return ValidateTimeSelection('{0}', '{1}', 'divMonOfficeStart', 'divMonOfficeEnd')", ddlMonOfficeStart.ClientID, ddlMonOfficeEnd.ClientID));

First off, I'm not sure if the above approach is necessary with Atlas, but the next question is how to handle this in javascript:

Do I simply get the clientid of the dropdownlist and do my 'normal' javascript - or at this point do I try to 'cast' this dropdownlist object on the client side to the Sys.UI.Select object?

I see this example here:http://atlas.asp.net/docs/util/srcview.aspx?path=~/atlas/samples/controls/simple_control.src - but in this example, these are 'html' elements, not .net server side controls?

In the above attribute, the script might look like this:

<scripttype="text/javascript">

function ValidateTimeSelection(g_ddl1, g_ddl2, g_div1, g_div2) {
var dd1 = ($(g_ddl1));
...
}

</script>

in this line here: var ddl = ($(g_ddl1)) I'd rather like to do something like:

var dd1= new Sys.UI.Select($(g_ddl1));

and utilize the Atlas script library.

Hopefully this makes sense :)

You can simply continue to build your custom control with regaulr JavaScript that is rendered by the control through the Page.ClientScript.RegisterXXXScript methods. Where your 'behavior' is simple, this might still be the best approach.

However, if you wish to build a new control that makes use of the Atlas libraries and perform much more rich behavior in the client, then you can begin to develop custom controls that implement IScriptControl, that can then render the required xml-script (declarative Atlas script) to the client. You'll need of course to ensure that there is a Scriptmanager in the page, in order to render your script. This means that you can divorce yourself from writing complex JavaScript etc.

If you have bew custom behaviors that you want your custom control to make use of, then you could potentially build Atlas client-side behaviors/controls that agfain you can render through the custom control. This would also yield those client-side components for other client-side rich applications.

Prefix for AJAX Extensions CTP

Hi all,

in the migration guide it says that the AJAX Extensions CTP prefix will stay at "atlas:" but when I add a reference to my EXISTING project it has the prefix "cc1:" (in other words it hasn't been defined yet in the )

<%@dotnet.itags.org.RegisterAssembly="Microsoft.Web.Preview"Namespace="Microsoft.Web.Preview.UI"TagPrefix="cc1" %>

The workaround (for users) is obvious (changing the TagPrefix) but I wanted you guys know about it.

For the fix it would be as simple as adding the TagPrefix to the assembly something like:

[assembly:TagPrefix("Microsoft.Web.Preview","atlas")]

PD: It works correctly though when I create a NEW project using the installed template in VS.NET 2005 (project template that generates AJAXCTPEnabledWebSiteX projects).

So what's the difference? It's the same dll right?

Regards,

Pieter

Hi,

I think the prefix is being registered in the web.config file of the template website.


Yes, but the guide asks to add these while migrating:

<addtagPrefix="atlas"namespace="Microsoft.Web.Preview.UI"assembly="Microsoft.Web.Preview"/>

<addtagPrefix="atlas"namespace="Microsoft.Web.Preview.UI.Controls"assembly="Microsoft.Web.Preview"/>

Still the prefix was set to "cc1"... on EXISTING pages, not on NEW pages within existing projects. Anyway, it's a minor issue.


hello.

well, i think the prefix wasn't defined by default by the team on the atlas dll. so, if you don't define it explicitly, you'll get a default prefix while droping the controls on a page.

Saturday, March 24, 2012

Problem adding atlas controls to existing web form

I created an atlas web site from the Atlas Template and added some files from another web site, so I tried to add <atlas:ScriptManager...> tag, but VS2005 didn't recognize Atlas (now ASP.Net AJAX) tags.

How can I add Atlas to existing ASP.Net web sites?

i'll need to register the "altas" tag in your web.config file.

I've discovered the problem. Atlas intellisense doesn't work in projects on network shares, so I installed Visual Source Safe and now it recognizes as being run locally.

Problem adding Atlas to an existing site

I have created a test atlas site and successfully used the update panel with some dropdown lists. Now I want to incorporate Atlas into an existing web site. I created a test page in the existing web site and recreated my test page in the existing site. The Atlas components to not seem to work... instead of an ajax update it is doing a full postback.

Here are the things I've checked:

- Atlas dll is included in bin
- Web.config file is updated and matches the test site config exactly
- Test web page is exactly the same as on the test site
- The .asbx extension is registered correctly
- The web site is configured for .Net 2.0

I'm not even sure how to figure out what else is going on here. Any other suggestions or things I can look at here? Thanks!

hello.

have you created a simple page on that site? if so, post it here so that we can see if there's anything wrong with it or if it's a configuration problem...


I have done a simple page on the test site (which works) and the exact same page in the existing site (which doesn't work) so I'm not sure the code provides any value. But here is another clue. When I add the trigger to the update panel through the designer, switch to code view, and then back to designer I get an "error creating control"

It says: Triggers could not be initialized. Triggers could not be added to the collection. Details: Object does not match target type.

Here is the web page code:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="IssueTest.aspx.cs" Inherits="ProjectTrack_IssueTest" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" 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 id="Head1" runat="server"> <title>Untitled Page</title> </head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </atlas:ScriptManager> <asp:DropDownList ID="ClientsDDL" runat="server" DataSourceID="RDI_DB" DataTextField="CO_NAME" DataValueField="Client_ID" OnSelectedIndexChanged="ClientsDDL_SelectedIndexChanged" AutoPostBack=true> </asp:DropDownList><atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional"> <Triggers> <atlas:ControlEventTrigger ControlID="ClientsDDL" EventName="SelectedIndexChanged" /> </Triggers> <ContentTemplate> <asp:DropDownList ID="ProjectsDDL" runat="server" DataTextField="PROJ_NAME" DataValueField="PROJECT_NO" AppendDataBoundItems=true AutoPostBack="True" OnSelectedIndexChanged="ProjectsDDL_SelectedIndexChanged"><asp:ListItem>Select a client</asp:ListItem> </asp:DropDownList> </ContentTemplate> </atlas:UpdatePanel> <asp:DropDownList ID="PhaseDDL" runat="server" DataTextField="DESCRIPTION" DataValueField="PHASE" AppendDataBoundItems=true AutoPostBack="True"><asp:ListItem>Select a project</asp:ListItem> </asp:DropDownList> <asp:DropDownList ID="TaskDDL" runat="server" DataTextField="TASK" DataValueField="TASK" AppendDataBoundItems=true><asp:ListItem>Select a phase</asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="RDI_DB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [Client_ID], [CO_NAME] FROM [CLIENTS]"></asp:SqlDataSource> <asp:SqlDataSource ID="ProjectListDB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [PROJECT_NO], [PROJ_NAME] FROM [PROJ_NO] WHERE ([CLIENT_ID] = @.CLIENT_ID)"> <SelectParameters> <asp:ControlParameter ControlID="ClientsDDL" Name="CLIENT_ID" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="PhaseListDB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [PHASE], [DESCRIPTION] FROM [PHASE] WHERE (([CLIENT_ID] = @.CLIENT_ID) AND ([PROJECT_NO] = @.PROJECT_NO)) ORDER BY [DESCRIPTION]"> <SelectParameters> <asp:ControlParameter ControlID="ClientsDDL" Name="CLIENT_ID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="ProjectsDDL" Name="PROJECT_NO" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="TasksListDB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [TASK], [DESCRIPTION] FROM [TASK] WHERE ([PHASE] = @.PHASE)"> <SelectParameters> <asp:ControlParameter ControlID="PhaseDDL" Name="PHASE" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource>   </form></body></html>

hello.

tell me something: can you run the following code with success:

<atlas:scriptmanager runat="server" id="manager" enablepartialrendering="true" />

<atlas:updatepanel runat="server" id="panel">
<contenttemplate>
<asp:button runat="server" Text="Submit" />
<%=DateTime.Now.ToString() %>
</contenttemplate>
</atlas:updatepanel>


Same results... in my existing web site it causes a postback. In my test web site it does an ajax update (no postback). Does that tell you anything? Thanks.

hello again.

one more question:

open the previous page on the browser, right click on it and look at the source code. find the script element that is used to load the js file (you might have several elements that user the webresource.axd on the page; in this case, you'll have to repeat it to all the items you find). copy the address that is in the src attribute of the script element and add it to the url of the page you have in the browser (you'll probably have to delete a portion of the url before adding the value you've copied from the source file).

can you get the file? ie, can you get the js atlas file? if you can't get the file (you should see the tradidional save dialog), then you have a iis configuration problem...

Problem getting AJAX work on content page

Hi,

I want AJAX - enable existing content ASP .NET page. After updating web.config all seemed OK. But ...

I'm still getting full postback even on this simple testing page:

<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="server">
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:Label ID="Label1" runat="server" Text="Label"><%# DateTime.Now.ToString()%></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

As you guess ScriptManager is on master page and I left its properties default.

Any idea what am I missing?

You are missing your triggers!!!!

<triggers>

<asp:AsyncPostBackTrigger controlID="NameofYouControl" EventName="NameofEventThat triggers refresh"> </<asp:AsyncPostBackTrigger>

</triggers>


You are missing your triggers!!!!

<triggers>

<asp:AsyncPostBackTrigger controlID="NameofYouControl" EventName="NameofEventThat triggers refresh"> </<asp:AsyncPostBackTrigger>

</triggers>


<triggers></triggers> goes after <ContentTemplate></ContentTemplate>


Triggers shouldn't be needed in that example... There must be something wrong with the web.config, other code on the page, or possibly a configuration issue in IIS.


i would say it's the web.config issue.