Showing posts with label controls. Show all posts
Showing posts with label controls. Show all posts

Wednesday, March 28, 2012

AJAX Calander Behind other Controls

Hi All,

I am using the Ajax Calander Control, I have it working in all and I have it writing to a textbox. I have this placed on a form where there are dropdown lists. It seems that the Cal. control always appears behind these dropdownlists instead of infront, therefore making it not visible.

Any work arounds?
Thanks in advance!!!
Tim

Hi tbraga,

I do not notice this behavior and I use VS.NET 2005 sp1 / Ajax Extentions 1 / AjaxControlToolkit 10920.

Can you post code that replicates this behavior?

Kind regards,
wim


Hi Tbraga,

As far as I know, this is a common issue. We suggest that you should upgrade your AJAX Control Toolkit to the latest version. If this doesn't work, you can set its zIndex properties. For example, $find("CalendarExtender's BehaviorID")._popupDiv.zIndex = large enough number.

function pageLoad(){
$find("CalendarExtender's BehaviorID").add_shown(resetZIndex);
}

function resetZIndex(){

$find("CalendarExtender's BehaviorID")._popupDiv.zIndex = value.

}

I hope this help.

Best regards,

Jonathan

AJAX Beta 2 and Custom Controls

I just finished installing Beta 2 and now none of my user controls validate.

For example:

<%@dotnet.itags.org.RegisterSrc="PageTop_Icons.ascx"TagName="Icons"TagPrefix="Toolbar" %>

<Toolbar

:IconsID="m_Icons"runat="server"/>

...immediately generates this error:

Error 103 Unknown server tag 'Toolbar:PageTop_Icons'.

The control in question is just a bunch of hyperlinks -- nothing fancy.

I've tried deleting the registration and the control and dragging & dropping a new one. It's automatically assigned the uc1 TagPrefix, the control is visible in the Design window, but still generates the error.

This is happening on every page that uses a User Control. Everything worked fine before I upgraded to Beta 2. Does anyone know what's going on?

That's an interesting one. I can't say based on what you have hear, but if it helps I can tell you that it's not a general problem; I have user controls working just fine w/ Beta 2.

Offhand, I'd probably look at the ascx files and make sure they're not referencing anything in the old Atlas stuff that might now be causing them a compilation error. Failing that, the web.config would be the next place I looked, to make sure all the changes were done correctly.


hello.

any chances of building a simpler control + page and post it here so that we can reproduce your problem?


I wish I had that kind of time. We're trying to get this .net conversion released asap, so the Ajax stuff will have to wait.


Well, like I said, the control in question is nothing more than a set of hyperlinks. Per your suggestion, I spent a good hour rechecking the webconfig and didn't see anything out of place. I tried commenting out some of the new Ajax entries (like the tag mapping) and that just made things even worse. I've since rolled back to working versions. We'll revisit Ajax later on after our initial release.

AJAX Behaviours -- documentation

Hi!

Can someone please point me to the a place, where Behaviours are explained? I found that some controls have custom behaviours and I found a client side Behaviours class.

I'd like to modify the onkeypress handler of a asp:TextBox control -- is Behaviour the right place to do so?

Thanks,

Miha.

mihav:

Hi!

Can someone please point me to the a place, where Behaviours are explained? I found that some controls have custom behaviours and I found a client side Behaviours class.

It is covered in the docs and explained with code by long time AJAX user Garbin. Hope this helps.

http://ajax.asp.net/docs/ClientReference/Sys.UI/BehaviorClass/default.aspx

http://aspadvice.com/blogs/garbin/archive/2006/01/23/14786.aspx


Thanks. The Garbin's post looks helpful -- the Behaviour class documentation is useless (I found that before) in helping understand what Behavirours are all about.

I'd like to change the the onkeypress event handling of the TextBox control to do a postback on every keypress... I hope behaviours are the right direction to go to?

Thanks,

Miha.


What you want is easier with JavaScript per the thread below, if you choose to use AJAX search Garbin's blog for all related posts and modify the code as needed. Hope this helps.

http://forums.asp.net/thread/1348454.aspx


Thanks. I pretty much solved the problem with "ordinary" input type=textbox field and a javascript event handler. I did find out, though, that if I remove the <asp:TextBox> from the page (although I am not using it) the __doPostback updates the whole page, not just the UpdatePanel content. To explain better:

Page has an ordinary text box andasp:TextBox on it. Both text boxes are outside of the update panel. Within an Update panel, there is a AsyncPostBackTrigger, referring to asp:TextBox control (which I amnot using). When I use the ordinary text box, everything works (meaning that the updates only affect update panel). So, if I remove the AsyncPostBackTrigger, the __doPostBack, triggered by ordinary textbox updates the whole page. If I try to wire AsyncPostBackTrigger with ordinary textbox, I get an error

A control with ID 'SearchBox' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
Because there is no control. (it is just markup...).  Is there a way to wire ordinary form field (not asp.net control) with updatepanel?
Miha 


hello.

Triggers are only meant to be used with server side controls. if you have a regular HTML control which starts a postback, then you can try to add the client id of that control to the _asyncPostbackControlsIDs collection maintained by the pagerequestmanager object.


Luis, can you please help me with _asyncPostbackControlsIds collection? Where do I find it? The PageRequestManager does not seem to have it. I've put a script block at the end of the aspx file and I got an undefined value for _asyncPostbackControlsIds.

Aha, I found out it is a typo. But nontheless, the code doesn't work. There must be another way to register this HTML control with pagerequest manager object. The code I tried is:

 var prm = Sys.WebForms.PageRequestManager.getInstance(); prm._asyncPostBackControlIDs.add('SearchBox');
Thanks, Miha.

Sorry. I'm a bit rusty with javascript.

So, I added it to the array.

If I remove the trigger <asp:AsyncPostBackTrigger ControlID="SearchBoxx" EventName="TextChanged" /> from the <triggers> in aspx, the array size decreases to 0, and is 1 after I add the 'SearchBox' HTML control to it. It still doesnot work, because it now refreshes the whole page again. There is something missing to this story. Something to tell the pagerequest manager to only update the updatepanel? The markup generated for the textboxes isidentical in both cases. The only difference on the page is this:

Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], ['SearchBoxx'], [], 90);

When there is no <trigger> present, the second parameter is empty. And I tried to add that to a script at the end of the ASPX file, but it still refreshes the whole page...

Aaaaa. I would really like to get rid of the asp:TextBox control, as it is doing nothing on the page...

Miha


hello.

try running this:

<%@. Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

if (ScriptManager1.IsInAsyncPostBack &&
Request.Params["__EVENTTARGET"] == "txt")
{
panel.Update();
}
}
</script>
<!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>
<script>
function main()
{
// Add Client Code here
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager
<asp:updatepanel runat="server" id="panel" UpdateMode="Conditional">
<ContentTemplate>
panel 1:
<%= DateTime.Now.ToString() %>
</ContentTemplate>
</asp:updatepanel>

<asp:updatepanel runat="server" id="Updatepanel1" UpdateMode="Conditional">
<ContentTemplate>
panel 2:
<%= DateTime.Now.ToString() %>
</ContentTemplate>
</asp:updatepanel>

<input type="text" id="txt" onchange="__doPostBack('txt','');"; />
</form>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded( function() {
Sys.WebForms.PageRequestManager.getInstance()._asyncPostBackControlClientIDs.push( "txt" );} );
</script>
</body>
</html>


Luis, this is excellent. It works. I'll see what changes I have to make to make my example work and I'll post the solution to my problem (should someone else have the same problem).

Tnx,

Miha.


3 months later, and out of AJAX RC, the solution to this problem was this:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded( function() {
Sys.WebForms.PageRequestManager.getInstance()._asyncPostBackControlClientIDs.push( "txt" );} );

Thanks again,

Miha.

Monday, March 26, 2012

ajax autocomplete text

Hi,

I downloaded ajax 1.0 beta 2 and the controls toolkit.

I want to make an autocomplete textbox that while typing letters in it,

a dropdownlist is opened under it and filled by ajax with every new letter typed in the textbox.

When choosing a value in the ddl, it disappears and the selected value inserted into the textbox.

I saw such examples in atlas, but I prefer to use ajax 1.0 , since I relized that this is the recommended product.

Is there any control in the controls toolkit for that ? Did somebody here tried it before ?

Thanks a lot !

AutoCompleteExtender currently lives in the Futures CTP:http://www.microsoft.com/downloads/details.aspx?FamilyId=29B6B62B-A25A-498D-AA14-90B68CF2E392&displaylang=en

AJAX Async postback

Hi

I have a WebForm in this web form i am dynamically loading 6 User Controls these user controls has ajax update panel. & these update panel have web controls.

Now when i click any control of any UCs that click is causing a page post back. due to this all my other cotrols are getting reloaded & respectibve UCs page load is getting fired. I want to restrict this.

I want to add condition on each UC's page load event to check whether this postback is caused due to some other UC's event. If it is caused due to some other UCs event then dont process anything. If it is caused due to its own event then only process it.

I need this cause i see the performnce impact of this.

Hi,

if you set UpdateMode rproperty for each UpdatePanel to "conditional" you can avoid updating all update panels on every click. You will also need to check that your ChildrenAsTriggers property is set to "true".

However, if you do some time consuming procesing on the server you will still need to check which control caused asyncpostback.

-yuriy
http://couldbedone.blogspot.com


Hey yuriy

Thanks for your response. Can you jsut tell me how can i check which control caused Asyncpostback...thats what am lookinh for.


Property of the ScriptManager: AsyncPostBackSourceElementID

Ajax and WebParts

I am building a site that uses Web Parts and Ajax. In each Web Part I have a user control that uses Ajax to update itself. All the user controls use Ajax. Everything works well until, I close one of the web parts.When I do this and click on any of the controls to do an update, I get an error Sys.InvalidOperationException: Could not find UpdatePanel with ID <name of the panel that contained the web part that I closed>. If it is being updated dynamically then it must be inside another update panel.

Since all the controls use Ajax, how can i overcome the fact that the script is looking for the controls found in another Web Part.

1.Try to take a look at this useful blog about Dragging and dropping ASP.NET 2.0 Web Parts in Firefox and Safari with ASP.NET AJAX -http://blogs.neudesic.com/blogs/david_barkol/archive/2006/11/07/631.aspx
2.Try to read this thread - http://forums.asp.net/thread/1486784.aspx to get some ideas.
Here are some sample codes about using webParts in Ajax for your reference.
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upPortal" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:WebPartManager ID="wpmPortal" runat="server">
</asp:WebPartManager>
<div class="wrapper">
<asp:CatalogZone ID="czPortal" runat="server">
</asp:CatalogZone>
</div>
<div class="wrapper">
<div id="wz1">
<asp:WebPartZone ID="WebPartZone2" runat="server" HeaderText="Column 1">
<ZoneTemplate>
<asp:Wizard ID="Wizard1" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<%--<uc1:ThemeSelector ID="ThemeSelector1" runat="server" EnableTheming="True" />--%>
</ZoneTemplate>
</asp:WebPartZone>
</div>
<div id="wz2">
<asp:WebPartZone ID="WebPartZone3" runat="server" HeaderText="Column 2">
<ZoneTemplate>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black"
DayNameFormat="Shortest" Font-Names="Times New Roman" Font-Size="10pt" ForeColor="Black"
Height="220px" NextPrevFormat="FullMonth" TitleFormat="Month" Width="312px">
<SelectedDayStyle BackColor="#CC3333" ForeColor="White" />
<TodayDayStyle BackColor="#CCCC99" />
<SelectorStyle BackColor="#CCCCCC" Font-Bold="True" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#333333" Width="1%" />
<DayStyle Width="14%" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="White" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" ForeColor="#333333"
Height="10pt" />
<TitleStyle BackColor="Black" Font-Bold="True" Font-Size="13pt" ForeColor="White"
Height="14pt" Font-Names="Arial" />
</asp:Calendar>
</ZoneTemplate>
</asp:WebPartZone>
</div>
<div id="wz3">
<asp:WebPartZone ID="WebPartZone4" runat="server">
<ZoneTemplate>
<asp:Login ID="Login1" runat="server">
</asp:Login>
<asp:Login ID="Login2" runat="server">
</asp:Login>
</ZoneTemplate>
</asp:WebPartZone>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div
Can you send your website to my email:v-jicwan@.microsoft.com? I'd?like?to?test?it.

Hi Jasson,

Thanks for the information. I found the problem. Each of my user controls are inside an UpdatePanel tag. I had missed adding the attribute UpdateMode="Conditional". Once I added this attribute everything worked fine.

Thanks once again


Hi vinod,

I have the same problem. i have try your solution ...its working but it will referesh the page..

i want to work it without refereshing the page. is it possible.

waiting for your reply.

thanks in advance

vishnu


Hi vinod,

I have the same problem. i have try your solution ...its working but it will referesh the page..

i want to work it without refereshing the page. is it possible?.

please try to send sample code.

waiting for your reply.

thanks in advance

vishnu

Saturday, March 24, 2012

AJAX and web server controls

Please some one explain me the following in ajax.

1) Is it necessary that I have to use html controls instead of web server control in order to support AJAX in my web page?. (I know we can use Magic AJAX – penal control to do the same. But I don't want to use any third party component or library).

2) As per my understanding in AJAX like technology I can send some information to the server and I can get some info from the server based on the info sent. But if I want to add a new row to my web server datagrid control. How can we do this with AJAX. I mean if I add a blank row to my collection class then how will I reflect that in UI.

3) Is there any simple code sample available in the net that demonstrates the web server control manipulation with AJAX.

Hi,

you can use normal web controls when you use Atlas, which is the AJAX implementation/framework from Microsoft.

For more information and quickstartsplease take a look here.

Grz, Kris.

AJAX and User controls which emit and execute Javascript

I have a user control which emits a bit of Javascript in its Render(HtmlTextWriter) method. When I use this control on a simple ASP.NET page with full page postbacks, it emits the Javascript which is then run by the browser.

However, when I naively drop this control into an UpdatePanel, when the panel gets updated the control renders the Javascript into the right place on the page, but the script is not run, so the control does not appear correct. Is it possible to achieve this somehow? (It ought to be, as we have an alternative AJAX package which does it without modification)

In order to achieve this you should not generate the script text in the Render method. Instead you should use ScriptManager.RegisterClientScriptBlock function. This will work for both postbacks as well as partial postbacks.

I've moved the script into a RegisterClientScriptBlock function, but it still appears not to be executed... here's my control's test OnPreRender() which does the registering, and I can see in the debugger it's called on both full and partial postbacks, but the Javascript alert() only fires off on full postbacks. Any ideas?

protectedoverridevoid OnPreRender(EventArgs e)

{

base.OnPreRender (e);if(Visible)

{

StringBuilder sb =newStringBuilder();StringWriter writer2 =newStringWriter(sb);

writer2.Write(

"<script type=\"text/javascript\">");

writer2.Write(

"//<![CDATA[");

writer2.Write(

"alert('hello world!');");writer2.Write("//]]>");

writer2.Write(

"</script>");

Page.ClientScript.RegisterClientScriptBlock(

this.GetType(),"__Map", sb.ToString());

}

}


Use ScriptManager.RegisterClientScript block not Page.ClientScript.registerClientScriptBlock
Sorry, my mistake. It works fine now... many thanks!

J.

AJAX and user controls

Hi

First of all, I use AJAX 1.0. I have bumped into following problem. I have aspx page (Default.aspx) with ScriptManager on it. It has header, left menu and content layout. On each of those I have UpdatePanel in which I have PlaceHolder. I use those placeholders to load uc controls.

What I want to acheive is to load default uc-s in every ph on Page Load which works ok. Menu ph will always have default uc loaded. When I click on menu item (which is in menu control on menu uc in menu ph), I want to change header uc and content uc -> load new uc-s in their ph-s. This also works ok but I doubt my method in acheiving this.

My page load code:

1using System;2using System.Data;3using System.Configuration;4using System.Web;5using System.Web.Security;6using System.Web.UI;7using System.Web.UI.WebControls;8using System.Web.UI.WebControls.WebParts;9using System.Web.UI.HtmlControls;1011public partialclass _Default : System.Web.UI.Page12{13#region UC ViewState14public string currentUCM15 {16get17 {18if (ViewState["currentUCM"] !=null)return ViewState["currentUCM"].ToString();19else return null;20 }21set { ViewState["currentUCM"] =value; }22 }23public string currentUCH24 {25get26 {27if (ViewState["currentUCH"] !=null)return ViewState["currentUCH"].ToString();28else return null;29 }30set { ViewState["currentUCH"] =value; }31 }32public string currentUCC33 {34get35 {36if (ViewState["currentUCC"] !=null)return ViewState["currentUCC"].ToString();37else return null;38 }39set { ViewState["currentUCC"] =value; }40 }41#endregion4243 protected void Page_Load(object sender, EventArgs e)44 {45// menu46if (currentUCM !=null)47 {48 phMenu.Controls.Add(LoadControl(currentUCM));49 }50else51 {52 currentUCM ="~/uc/uc_m1.ascx";53 phMenu.Controls.Add(LoadControl(currentUCM));54 }5556// head57if (currentUCH !=null)58 {59 phHead.Controls.Add(LoadControl(currentUCH));60 }61else62 {63 currentUCH ="~/uc/uc_h1.ascx";64 phHead.Controls.Add(LoadControl(currentUCH));65 }6667// content68if (currentUCC !=null)69 {70 phMainContent.Controls.Add(LoadControl(currentUCC));71 }72else73 {74 currentUCC ="~/uc/uc_c1.ascx";75 phMainContent.Controls.Add(LoadControl(currentUCC));76 }77 }78}
Code in my uc_m1.ascx (menu) is as follows:  
1using System;2using System.Data;3using System.Configuration;4using System.Collections;5using System.Web;6using System.Web.Security;7using System.Web.UI;8using System.Web.UI.WebControls;9using System.Web.UI.WebControls.WebParts;10using System.Web.UI.HtmlControls;1112public partialclass uc_uc_m1 : System.Web.UI.UserControl13{14protected void Page_Load(object sender, EventArgs e)15 {1617 }1819protected void mnuMain_MenuItemClick(object sender, MenuEventArgs e)20 {21string currentUCM ="~/uc/uc_m" + e.Item.Value +".ascx";22string currentUCH ="~/uc/uc_h" + e.Item.Value +".ascx";23string currentUCC ="~/uc/uc_c" + e.Item.Value +".ascx";2425// setting ViewState on page26 Page.GetType().GetProperty("currentUCM").SetValue(this.Page, currentUCM,null);27 Page.GetType().GetProperty("currentUCH").SetValue(this.Page, currentUCH,null);28 Page.GetType().GetProperty("currentUCC").SetValue(this.Page, currentUCC,null);2930 PlaceHolder phH = (PlaceHolder)this.Page.FindControl("phHead");31 phH.Controls.Clear();32 phH.Controls.Add(LoadControl(currentUCH));3334 PlaceHolder phC = (PlaceHolder)this.Page.FindControl("phMainContent");35 phC.Controls.Clear();36 phC.Controls.Add(LoadControl(currentUCC));3738// debug39 lblClicked.Text = (Convert.ToInt32(lblClicked.Text) + 1).ToString();40 }41}42
...here I set what gets loaded and override Page Load-s loaded controls, and then use reflection to set ViewState on Page through public property. I tried
to use ViewState directly, but didn't work. Can I update ViewState somehow?
Anyway, when I do this, I get "Failed to load viewstate...control tree doesn't match...".
Is there a way to go arround this? Another solution? Because I would like to use those similar to windows forms, just open form I need. And those uc I load
will have forms on them.
Thanx
If I remove reflection, leave ViewState as is and simply put another update panel in each UC, can I then refresh page only inside UC's update panel and refresh *global update panel based on condition?
Ok, I solved ViewState problem by simply using Session instead. It works better but not correct yet. Also there might be bug in AJAX, I have script error on page saying 0.cells is not object. Problem that remains is how to postback on uc control. My first postback doesnt work, only next ones do. I think it is because of event registration happening too late.

Ajax and user controls

hi all,

i have a master page whith some aspx pages that inherit from him , each page has some user controls each control has Ajax functionality

the question is where to put the script manager

    one on the master page.one on each aspx page.one on each user control,

thanks Daniel

I have found it seems to work best on the masterpage when you have controls using ajax on many content pages.

AjaxButter


YOu can't put more than one on the page, so if you have them both in the master and in a page, you should expect to see an error. Instead, put it on the Master, and then have proxies on the pages and controls

ajax and page_PreInit

Can someone please explain this to me.

Ive been trying to add some controls to a placeholder situated within a updatepanel.

According to microsoft i should create all dynamic controls in the page_preinit method. However when i did this the placeholder object was null.

When i moved the placeholder out of the updatepanel everything worked as expected

I moved the placeholder back into the updatepanel and moved the code to the page_preload method and i can now access the placeholder fine.

Im presuming that anything within an updatepanel cannot be access in the page_preiinit method, but can someone explain why.

Thanks in advance

Hi, I am having the same problem. Did you ever get an answer as to why this happens?

Thanks,

Steve

AJAX and Membership API

Hi All,

I have grown fed up with the restrictions placed on using the Login Controls provided by VWD, so I've decided to build my own controls and then call on the membership API class to insert records. I mainly did this to allow my application to use AJAX on the login features, but I have run into a problem.

Here is the code for my problem:

 
"ScriptManager1" runat="server" /> "UpdatePanel1" runat="server"> "Button1" runat="server" Text="Button" OnClick="Button1_Click" /> "LoginName1" runat="server" /> "msg" runat="server" Text="Label"> "LoginStatus1" runat="server" />

It is a simple page that has a login button, and when you click the button it runs this code:
protected void Button1_Click(object sender, EventArgs e) {if (Membership.ValidateUser("Brainify","BrainifyPassword")) { FormsAuthentication.SetAuthCookie("Brainify",true); msg.Text ="Login success!!!. Please check your user name and password and try again."; }else { msg.Text ="failed"; } } }

The code will try to validate a user (hardcoded) that I've put into the database. And if successful it will cause the msg label to change text. That works fine. But I would also like it change the the loginname control. This is all done through AJAX.

The problem is when I click on the button once, it validates and it changes the msg label to what I want. How the login name control never appears. I actually have to click on the button ONE more time to get the login name control to display the username! I have NO Idea what is going on...it appears AJAX is working, but I don't know why I have to click the button twice for everything to appear.

Any help would be greatly appreciated.Hi,

This is because the LoginName is determined by the current request's?user identity. When you click the button to login, the request?still doesn't contain a valid UserName.
The value can only be retrieved in the requests after this. So that an additional click is required.

You can use?Sys.Services.AuthenticationService to authenticate on the client before a postback happens.
Like this:

<"Button1" runat="server" Text="Button"?OnClientClick="javascript function that invokes Sys.Services.AuthenticationService" OnClick="Button1_Click" /
Hope this helps.

Wednesday, March 21, 2012

Ajax and Expression Web

Hi Guys,

Is it possible to add the Microsoft Ajax Framework to Expression web so that the controls show up in the Expression Web toolkit ?

If not is a version going to be availble for Expression web ?

Kind Regards

Andy

I would really like to know this as well. If Expression Web is the future of front-end web development, why can't I use the official ASP.Net AJAX components in my projects? Is there some other way to work with developers using Visual Studio 2005 and the new control toolkit?

Does anyone have any information on this?

I'd really like to know if this is possible. I'd agree that it is insane if not! I wish Microsoft would consolidate their web design/development products into one (preferably Visual Studio).

Thanks in advance.


I found this link about the topic http://blogs.msdn.com/andrewj/archive/2006/12/13/custom-asp-net-controls-and-expression-web.aspx , but it talks about using the GAC. Can someone from MS chime in and tell us if our controls must be in the GAC to use them in expression web?

Thanks,

Jon


You can access the ajax items in Expression provided the web.config is setup to use MS Ajax. What I did was create a project using the ajax web template (control or just ajax) in Visual Studio 2005 and then opened up that project in Expression. The issue is the tags are available in the 'code' view, but you get an error in 'designer' mode. You'll also see this if you build user controls that reference 3rd party controls (like the RAD controls). I have not been able to get the designer to use the controls without this error so I'm assuming the designer does not know about the 'referenced' dll objects.

If you don't have VS Studio or the Ajax template, you can manually add the ajax support -- but it is a bit of a pain...

-Don


Andy

Easiest way is to open up to explorer windows, one to where you install the ajaxcontroltoolkit.dll and the other to windows\assembly.

Drag and drop the ajaxcontroltoolkit.dll into the assembly folder.

Add the following to each page which references controls from the toolkit, best to double check the version and publickeytoken - you can see the values in the assembly folder.

<%@. Register
Assembly="AjaxControlToolkit, Version=1.0.10606.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>


ToolkitScriptManager still can't display for some reason, I'll keep digging.

HTH

Rob


Thanks for that Rob, but why do we have to struggle to do it and why can Microsoft Visual Web Developer Express a free tool from Microsoft install the Ajax controls but the money costing Expression Web can't !!!

All I can say is . . . BRING ON THE NEXT VERSION OF EXPRESSION WEB . . . as the ability to add new controls easily is crucial, at the moment you have to build part in Expression Web and then open it in VWD Express to use Ajax, its just so annoying !!!


When I try to either drag n drop or copy/paste the system will not allow me to put the ajaxcontroltoolkit.dll into the Wndiows/Assembly directory.

There are seveal ajax controls I would like to use on my site but can not get them to work in Expression Web. We have just converted to using Expression Web for designing updates to our application. The tool is far superior to the old FrontPage but I am having some learning pain when trying to step up to ASP.NET and learn how to use it.


Has there been any progress made on this issue? I googled it a bit but didn't turn up too much.

I have just installed Expression Web and I am a bit hesitant to use it because the site I am currently designing makes heavy use of AJAX controls.

I did read a few things about using custom ASP.NET controls in Expression. About using GAC and editting your web.config. Will these same techniques allow Expression Web to fully integrate AJAX controls?

http://blogs.msdn.com/andrewj/archive/2006/12/13/custom-asp-net-controls-and-expression-web.aspx


So I got everything working. I figured I'd explain how for future viewers.

This is how you get Ajax and the AjaxControlToolkit working in Expression Web (code view w/ intellisense and design view with properties).

STEP 1 - In your sites web.config file you must have the following:

<system.web>
<pages>
<controls>
<addtagPrefix="asp"namespace="System.Web.UI"assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addtagPrefix="ajaxToolkit"namespace="AjaxControlToolkit"assembly="AjaxControlToolkit, Version=1.0.10920.16768, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
</controls>
</pages>

<compilationdebug="true">
<assemblies>
<addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<addassembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="AjaxControlToolkit, Version=1.0.10920.16768, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
</assemblies>
</compilation>
</system.web>

NOTE: The assmebly version and keys may vary depending on what version of the toolkit you have installed. These are simple enough to find in the sample website for the AjaxControlToolkit's web.config.

NOTE: Since the AjaxControlToolkit is referenced in the web.config you do not need to include <%@. Register Assembly... %> on each of your pages.

STEP 2 - Add the AjaxControlToolkit.dll to your site's bin folder.

STEP 3 - Add the AjaxControlToolkit.dll to GAC

This is simple. Open the Visual Studio Command Prompt (from Start menu) and navigate to the bin folder of your site and type d:\> gacutil /i AjaxControlToolkit.dll

Now open your site in Expression Web and everything should be working!


One thing I would like to add...

The line in <assemblies> for the AjaxControlToolkit has version info and a publicKeyToken that cannot be found in the web.config of the sample website and it will vary depending on the version of the Toolkit you have installed.

To find this info you can either write a small program (1 line of code really) or just put the following line into a Watch while you are debugging something:

System.Reflection.Assembly.LoadFile(@."[PathToAjaxControlToolkit]\SampleWebSite\Bin\AjaxControlToolkit.dll").FullName

This will give you the text to put in the assembly attribute for the <add assembly=""/> line.

The file you reference here must be the same one you add to the GAC.



Oh won't some kind soul come and mark my post as the answer?


Yeah, I had a problem getting that going too. A quick powershell script handed the info over for me. I guess Reflector would produce the same result as well.

PowerShell script:

$assembly = [System.Reflection.Assembly]::LoadFile("path\to\AjaxControlToolkit.dll")
$name = $assembly.GetName()
"<SafeControl Assembly=""{0}"" Namespace=""{1}"" TypeName=""*"" />" -f $assembly.FullName,$assembly.GetName().Name

Output:

<SafeControl Assembly="AjaxControlToolkit, Version=3.0.11119.25533, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TypeName="*" />

Ajax and Dynamically created controls.

I have an app where I add images to a panel based on what a user selects from a drop down list. Under internet explorer and opera it works fine. but the html code generated in firefox and netscape is missing the events. When I debug with IE or OPERA as default browser in vs 2005 events are fired. When Netscape or Firefox are set as default events (for the images) are not fired. I looked at the code being generated by the server and there are no events in the html code for the images. Here is what I get.

<li class="zipitem"><input name="zipselect1$ziprepeater$ctl01$selectbtn"id="zipselect1_ziprepeater_ctl01_selectbtn"class="imagebtn"src="images/selectbtn.gif"alt="Select"style="border-width: 0px;"type="image"><span id="zipselect1_ziprepeater_ctl01_ziplbl">12836</span></li><li class="zipitem"><input name="zipselect1$ziprepeater$ctl02$selectbtn"id="zipselect1_ziprepeater_ctl02_selectbtn"class="imagebtn"src="images/selectbtn.gif"alt="Select"style="border-width: 0px;"type="image"><span id="zipselect1_ziprepeater_ctl02_ziplbl">12851</span></li>
<li class="zipitem"><input name="zipselect1$ziprepeater$ctl03$selectbtn"id="zipselect1_ziprepeater_ctl03_selectbtn"class="imagebtn"src="images/selectbtn.gif"alt="Select"style="border-width: 0px;"type="image"><span id="zipselect1_ziprepeater_ctl03_ziplbl">12852</span>
this is just a code scrap. The page looks fine in all browsers but the Mozilla browsers dont work. You should be able to click on the images which takes and adds the zipcodes the images represent into a gridview. As I said works in IE and Opera fine.
 
 
 

See this is Browser compatibility issue....

Can you post some code details so it will help..

Which version of Firefox you used...

I suggest try yo use latest version...


It is a browser issue? I thought asp.net server side created the code for each browser. Any way if I.E worked the way it should I would not need Ajax to solve this problem. It is the only browser of the four I have tested that causes the screen to flash when clicking on the images. of course I could have some setting wrong which IE requires that the others don't.

The follow code produces a number of images on the page. When an image is clicked it gets put into a data grid.

see first post for code scrap generated for mozilla browsers . As can be seen there there is no event code created for the images.

As for code here is html source

<%@. Control Language="c#" AutoEventWireup="false" Codebehind="zip_selector.ascx.cs" Inherits="active.UserControls.zip_selector" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%
<br>
<div id="div_selectedzip">
<asp:label runat="server" id="lblSelZip"> Set of Selected Zipcodes: </asp:label><asp:button id="btnRemoveAll" runat="server" text="Remove All" visible="False"></asp:button><asp:repeater id=selectedzip runat="server">
<headertemplate>
<ul style="list-style-type: none">
</headertemplate>
<itemtemplate>
<li class="selectedzipitem">
<asp:label id="Label2" runat="server"><%#DataBinder.Eval(Container.DataItem, "zip_code") %></asp:label>
<asp:linkbutton id="removelnk" runat="server" commandname='<%# DataBinder.Eval(Container.DataItem, "zip_code") %>'>Remove</asp:linkbutton
</li>
</itemtemplate>
</asp:repeater>
<div style="CLEAR: both"></div> <!-- This is to make Opera load correctly for fieldsets -->
</div>
<br>
<div id="div_cntyzip">
<div id="instructTxt"><p>Enter one or
more zip codes in the text box separated by commas. Or you can add to set of selected zip
codes from a county. If you are interested in one of the <a onclick="window.open('glossary.htm', 'Glossary', 'width=432,height=270,toolbar=0,scrollbars=1,screenX=200,screenY=200,left=200,top=200')" href="http://links.10026.com/?link=javascript:void(0)" >non-standard zipcodes</a>, type one or more of the
following values separated by commas: <b>invalid,
illegible, unreported, irregular, or private</b>.</p></div>
<asp:label id="zipErrMsg" runat="server" forecolor="Red" visible="False">* Error:</asp:label>
<span>Zip Code:</span><asp:textbox id=txtZip runat="server"></asp:textbox><asp:button id=btnSelectZip runat="server" text="Add to Set"></asp:button>
<asp:Button id="btnAddAllZip" runat="server" Text="All NYS Zipcodes"></asp:Button><br>
<div style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" ms_positioning="FlowLayout">OR</div><br
<span>Add to Set of Selected Zipcodes from County: </span><asp:dropdownlist id=cntyzipddl runat="server" autopostback="True"></asp:dropdownlist>
<asp:repeater id=ziprepeater runat="server" OnItemCommand="ziprepeater_ItemCommand1" >
<headertemplate>
<ul style="list-style-type: none">
</headertemplate>
<itemtemplate>
<li class="zipitem">
<asp:imagebutton id="selectbtn" runat="server" cssclass="imagebtn" alternatetext="Select" imageurl="../images/selectbtn.gif" commandargument='<%#DataBinder.Eval(Container.DataItem, "cnty_code") %>' commandname='<%#DataBinder.Eval(Container.DataItem, "zip_code") %>'></asp:imagebutton>
<asp:label id="ziplbl" runat="server"><%#DataBinder.Eval(Container.DataItem, "zip_code") %></asp:label>
</li>
</itemtemplate>
<footertemplate>
</ul>
<div class="spacer"> </div>
</footertemplate>
</asp:repeater>
<div style="CLEAR: both"></div> <!-- This is to make Opera load correctly for fieldsets -->
</div>
<br
here is code behind page in c#

namespace active.UserControls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using active.DataAccessLayer;
using active.Common;

/// <summary>
/// Summary description for zip_selector.
/// </summary>
public class zip_selector : System.Web.UI.UserControl
{
#region Properties
protected System.Web.UI.WebControls.Repeater ziprepeater;
protected System.Web.UI.WebControls.Repeater selectedzip;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label zipErrMsg;
protected System.Web.UI.WebControls.Label lblSelZip;
protected System.Web.UI.WebControls.TextBox txtZip;
protected System.Web.UI.WebControls.Button btnSelectZip;
protected System.Web.UI.WebControls.DropDownList cntyzipddl;
protected System.Web.UI.WebControls.Button btnRemoveAll;
protected System.Web.UI.WebControls.Button btnAddAllZip;
protected bool bBadZipFound=false;
private int MAXZIP;

private int MAXZIPCOUNT
{
get {return 300;}
set {MAXZIP = value;}
}

public bool All_ZIP_SELECTED
{
get
{
object o = ViewState["All_Zip_Selected"];
if (o == null)
return false;
else
return (bool)o;
}
set { ViewState["All_Zip_Selected"] = value; }
}

private string CountyCode
{
get
{
object o = ViewState["CountyCode"];
if (o == null)
return "00";
else
return o.ToString();
}
set { ViewState["CountyCode"] = value; }
}

public DataTable SelectedZipTable
{
get
{

DataTable t = ViewState["SelectedZip"] as DataTable;
if (t == null)
{
t=new DataTable("SelectedZip");
DataColumn dc = new DataColumn("zip_code",System.Type.GetType("System.String"));
DataRow dr = t.NewRow();
t.Columns.Add(dc);
dr["zip_code"] = "None Selected";
ViewState["SelectedZip"] = t;
}

return t;
}
set { ViewState["SelectedZip"] = value; }
}
public bool BadZipFound
{
get
{
return bBadZipFound;
}
}
public event EventHandler BubbleClick;
#endregion

#region Page Events
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
zipErrMsg.Visible = false;
if (!Page.IsPostBack)
{
CountyList lstCounties = Lookups.Counties;

//Filter out the non-standard county codes. All nonstandard counties have a sort_order
//greater than 990.
DataView dv = lstCounties.Tables[0].DefaultView;
dv.RowFilter = "sort_order < 990";
//lstCnty.DataSource = lstCounties;
cntyzipddl.DataSource=dv;
cntyzipddl.DataMember = lstCounties.counties.TableName;
cntyzipddl.DataTextField = lstCounties.counties.cnty_nameColumn.ColumnName;
cntyzipddl.DataValueField = lstCounties.counties.cnty_codeColumn.ColumnName;
cntyzipddl.DataBind();

ListItem item= new ListItem("Select County","00");

cntyzipddl.Items.Insert(0,item);
cntyzipddl.SelectedValue = CountyCode;

BindZipRepeater();
BindSelectedZip();

}

}
protected override void OnPreRender(EventArgs e)
{
if (SelectedZipTable.Rows.Count > 0)
btnRemoveAll.Visible=true;
else btnRemoveAll.Visible=false;
base.OnPreRender (e);
}
#endregion

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
this.cntyzipddl.SelectedIndexChanged +=new EventHandler(cntyzipddl_SelectedIndexChanged);
this.ziprepeater.ItemCommand +=new RepeaterCommandEventHandler(ziprepeater_ItemCommand);
this.selectedzip.ItemCommand +=new RepeaterCommandEventHandler(selectedzip_ItemCommand);
this.btnSelectZip.Click += new System.EventHandler(this.btnSelectZip_Click);
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnRemoveAll.Click += new System.EventHandler(this.btnRemoveAll_Click);
this.btnAddAllZip.Click += new System.EventHandler(this.btnAddAllZip_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

#region User Public Methods

/// <summary>
/// Binds the zip selector datagrid to the results from list of zip codes retrieved by county
/// </summary>
public void BindZipRepeater()
{
DataSet dsZipSelect;
string cnty_cd = CountyCode;
DataTable dt;

dsZipSelect = Lookups.GetZipByCnty(cnty_cd);
dt = dsZipSelect.Tables[0];

//Add the option of selecting all zip codes in county
if (CountyCode!="00")
{
DataRow dr = dt.NewRow();
dr[1]="All County Zip";
dt.Rows.Add(dr);
}
/*//Add the option of selecting all NY zip codes
dr = dt.NewRow();
dr[1]="All NY Zip";
dt.Rows.Add(dr);
*/
ziprepeater.DataSource = dsZipSelect;
ziprepeater.DataMember = "ZipSelect";
ziprepeater.DataBind();

}

public void BindSelectedZip()
{
selectedzip.DataSource = SelectedZipTable;
selectedzip.DataMember = "SelectedZip";
selectedzip.DataBind();

int selectedCount = SelectedZipTable.Rows.Count;
lblSelZip.Text = "Set of Selected Zip Codes (" + SelectedZipTable.Rows.Count + " of " + MAXZIPCOUNT + " Max): ";

}
#endregion

#region Private Methods
private void lstCnty_SelectedIndexChanged(object sender, EventArgs e)
{
ListControl lstCnty = sender as ListControl;
if (lstCnty != null)
{
CountyCode = lstCnty.SelectedValue;
BindZipRepeater();
}
}

private void cntyzipddl_SelectedIndexChanged(object sender, EventArgs e)
{
ListControl lstCnty = sender as ListControl;
if (lstCnty != null)
{
CountyCode = lstCnty.SelectedValue;
BindZipRepeater();
}
}

private void ziprepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
OnBubbleClick(e);
string selectedZip = e.CommandName;
string selectedCnty = e.CommandArgument.ToString();
DataTable dt = SelectedZipTable;
zipErrMsg.Visible=false;
if (!All_ZIP_SELECTED)
{
//the zip is not already been added and the amount of selected zipcodes
//do not exceed MAXZIPCOUNT
if (dt.Rows.Count < MAXZIPCOUNT)
{
if (selectedZip == "All County Zip")
{
//Add all zips in the selected County
AddCountyZips();
}
else
{
AddSelectedZip(selectedZip);
}
}
else
{
zipErrMsg.Text = "You have exceeded the maximum of " + MAXZIPCOUNT.ToString() + " zip codes. Please narrow your search. <BR>";
zipErrMsg.Visible = true;
}
}
else
{
zipErrMsg.Text="All NYS zip codes have been selected. No need to add individual zipcode.<br>";
zipErrMsg.Visible=true;
}
}

private void selectedzip_ItemCommand(object source, RepeaterCommandEventArgs e)
{
string selectedZip = e.CommandName;
DataTable dt = SelectedZipTable;
string selectExpr = "zip_code ='" + selectedZip+"'";
DataRow[] foundRow = dt.Select(selectExpr);
zipErrMsg.Visible=false;

if (foundRow.Length >0)
{
dt.Rows.Remove(foundRow[0]);
if (selectedZip=="All NYS Zip")
{ All_ZIP_SELECTED = false;
}
BindSelectedZip();

}

}
//"Add to Set" button click method
private void btnSelectZip_Click(object sender, System.EventArgs e)
{
OnBubbleClick(e);
zipErrMsg.Visible=false;
//reset the select county table to avoid confusion
CountyCode="00";
cntyzipddl.SelectedValue = CountyCode;
BindZipRepeater();

if (!All_ZIP_SELECTED)
{
//parse and validate zip input string
string [] zips = zipinput_parser();
DataTable dt = SelectedZipTable;

//if valid zips are returned, add to Selected Zip table
if (zips != null)
{
foreach (string zip in zips)
{
//the zip is not already been added and the amount of selected zipcodes
//do not exceed MAXZIPCOUNT
if (dt.Rows.Count < MAXZIPCOUNT)
{
AddSelectedZip(zip);
}
else
{
zipErrMsg.Text = "You have exceeded the maximum of " + MAXZIPCOUNT.ToString() + " zip codes. Please narrow your search.<br>";
zipErrMsg.Visible = true;
break;
}
//blank out the zip textbox for another entry
txtZip.Text="";
} //end of foreach
} //end of if zip length==0

}
else
{
zipErrMsg.Text="All NYS zip codes have been selected. No need to add individual zipcode.<br>";
zipErrMsg.Visible=true;
}
}

public string[] zipinput_parser()
{
// split zip string between commas
string[] splitTxt = txtZip.Text.Split(new char[] {',',' '});
string validZips="";
string badZips="";
zipErrMsg.Text = "* Error: ";
zipErrMsg.Visible=false;
//check blank zip input
if (txtZip.Text == "")
{
zipErrMsg.Text += "Please enter a zip code value. <br>";
zipErrMsg.Visible = true;
}
else
{
string lowerZip;
//txtZip.Text = "";
foreach (string zip in splitTxt)
{
lowerZip = zip.ToLower();
lowerZip = lowerZip.Trim();
if (zip !="")
{
//check it is not one of the non-standard zip code values
if ((lowerZip != "private") &&(lowerZip != "invalid") && (lowerZip != "illegible") && (lowerZip != "unreported") && (lowerZip != "irregular"))
{ //zip code is invalid if zip is alpha or is not 5 digits long
if ((lowerZip.Length != 5)||!Validations.IsNumeric(lowerZip))
{
//zipErrMsg.Text = zipErrMsg.Text + lowerZip;
zipErrMsg.Visible = true;
//txtZip.Text = txtZip.Text + lowerZip + ",";
badZips= badZips + lowerZip + ",";
}
else validZips = validZips + lowerZip + ",";
}
else validZips = validZips + lowerZip + ",";
}
}
if (zipErrMsg.Visible)
{
bBadZipFound=true;
badZips = badZips.Remove(badZips.Length-1,1);
txtZip.Text=badZips;
zipErrMsg.Text = zipErrMsg.Text + badZips + " is not valid.";
if (validZips.Length>0)
{
zipErrMsg.Text += " Valid zips have been added to the selected zip table.";
}
zipErrMsg.Text += "<br>";
}
//remove last comma
if (validZips.Length>0) validZips = validZips.Remove(validZips.Length-1,1);
}
if (validZips =="")
return null;
else return validZips.Split(new char[] {','});

}

public string zipinput_parser(bool validateOnly)
{
// split zip string between commas
string[] splitTxt = txtZip.Text.Split(new char[] {',',' '});
string validZips="";
string badZips="";
zipErrMsg.Text = "* Error: ";
zipErrMsg.Visible=false;
//check blank zip input
if (txtZip.Text == "")
{
zipErrMsg.Text += "Please enter a zip code value. <br>";
zipErrMsg.Visible = true;
}
else
{
string lowerZip;
//txtZip.Text = "";
foreach (string zip in splitTxt)
{
lowerZip = zip.ToLower();
lowerZip = lowerZip.Trim();
if (zip !="")
{
//check it is not one of the non-standard zip code values
if ((lowerZip != "private") &&(lowerZip != "invalid") && (lowerZip != "illegible") && (lowerZip != "unreported") && (lowerZip != "irregular"))
{ //zip code is invalid if zip is alpha or is not 5 digits long
if ((lowerZip.Length != 5)||!Validations.IsNumeric(lowerZip))
{
//zipErrMsg.Text = zipErrMsg.Text + lowerZip;
zipErrMsg.Visible = true;
//txtZip.Text = txtZip.Text + lowerZip + ",";
badZips= badZips + lowerZip + ",";
}
else validZips = validZips + lowerZip + ",";
}
else validZips = validZips + lowerZip + ",";
}
}
if (zipErrMsg.Visible)
{
bBadZipFound=true;
badZips = badZips.Remove(badZips.Length-1,1);
zipErrMsg.Text = zipErrMsg.Text + badZips + " is not valid.";
zipErrMsg.Text += "<br>";
}
//remove last comma
if (validZips.Length>0) validZips = validZips.Remove(validZips.Length-1,1);
}
return validZips;

}
/// <summary>
/// Adds all the zip codes within a county
/// </summary>
private void AddCountyZips()
{
DataSet dsZipSelect;
string cnty_cd = CountyCode;
DataTable dt = SelectedZipTable;
DataTable cntyTable;
string zipCd;
int totalZip;

zipErrMsg.Visible=false;
dsZipSelect = Lookups.GetZipByCnty(cnty_cd);
cntyTable = dsZipSelect.Tables[0];
totalZip = dt.Rows.Count + cntyTable.Rows.Count;
if (totalZip < MAXZIPCOUNT)
{
foreach (DataRow aRow in cntyTable.Rows)
{
zipCd = aRow[1].ToString();
AddSelectedZip(zipCd);
}
}
else
{
zipErrMsg.Text = "You have exceeded the maximum of " + MAXZIPCOUNT.ToString() + " zip codes. Please narrow your search. <br>";
zipErrMsg.Visible = true;
}
}
private void AddSelectedZip(string zipcd)
{
DataTable dt = SelectedZipTable;
string selectExpr = "zip_code ='" + zipcd +"'";
DataRow[] foundRow = dt.Select(selectExpr);
if (foundRow.Length ==0)
{
DataRow dr = dt.NewRow();
dr[0]=zipcd;
dt.Rows.Add(dr);
BindSelectedZip();
}
}

private void btnRemoveAll_Click(object sender, System.EventArgs e)
{
SelectedZipTable.Clear();
zipErrMsg.Visible = false;
All_ZIP_SELECTED = false;
BindSelectedZip();
}

private void btnAddAllZip_Click(object sender, System.EventArgs e)
{
OnBubbleClick(e);
SelectedZipTable.Clear();
AddSelectedZip("All NYS Zip");
All_ZIP_SELECTED = true;
}
protected void OnBubbleClick(EventArgs e)
{
if(BubbleClick != null)
{
BubbleClick(this, e);
}
}
#endregion

protected void ziprepeater_ItemCommand1(object source, RepeaterCommandEventArgs e)
{

}

}
}

None of the click events for the images created on the fly fire as I said in first posting. You can see that the html generated by the server does not have any events.

Ajax and DataList feeding

I have a number of DataList controls in the same page which I want to repopulate with new information every so often (each one in a different interval) and render independently from the rest of the page. So each one of them is placed in a different UpdatePanel. These DataLists will be filled up with information retrieved from a DB.

My initial idea was to use an AJAX timer control for each UpdatePanel and then feed each DataList in its respective Tick even handler, but AJAX timer seems not to be working with more than a Timer in the same page. So my idea now is to assign and execution interval to a javascript function (by using window.setInterval) which will call a PageMethod. Since I can not directly bind the DataList within this PageMethod, the only soluction I see is to make the PageMethod return a list of objects. In this situation the problem I find is that I don't know, in case it is possible, how to bind the DataList from the JavaScript code. Moreover, what I want to bind is a list of custom objects, not base types.

Could someone give me some advice?

Try this article although it is Ajax Repeater but you can make it to work as DataList. http://dotnetslackers.com/articles/ajax/ASPNETRepeater.aspx

Ajax Accordion with Label Controls

Is it possible to have an ajax accordion control and the content and header portions with dynamic information on page_load?

<ajaxToolkit:AccordionPane ID = "AccordionPane4" runat = "server">
<Header>
<a href = "" onclick = "return false;" class = "accordionLink"> <asp:Label Id="lblHeader3" runat="server" </asp:Label></a>
</Header>
<Content>
<asp:LabelID="lblContent3" runat="server"></asp:Label>
</Content>
</ajaxToolkit:AccordionPane>

Fill in dynamically??

Thanks

Hi,

You may achieve like this:

AccordionPane ap = new AccordionPane();
MyAccordion.Panes.Add(ap);
LinkButton lb = new LinkButton();
lb.Text = "hello";
ap.HeaderContainer.Controls.Add(lb);

Hope this helps.


AccordionPane ap =new AccordionPane();

I am getting an error here. Do I have to add a reference like a

using System.Ajax? I currently have the ajax dll in the bin.


It's in the namespace AjaxControltoolkit