Showing posts with label toolkit. Show all posts
Showing posts with label toolkit. Show all posts

Wednesday, March 28, 2012

Dynamic Creation of AJAX Controls (w/Intellisense?)

Is there any way to make intellisense work for the AJAX Control Toolkit in the code behind pages? I'm trying to dynamically create controls in c#.

Thanks!

Hi Jerryp,

First , I think you should InstallAsp.Net 2.0 Ajax Extension V1.0 and then installAjax Control Toolkit. You can get them from this url: http://www.asp.net/ajax/ . If your project is an exsit which is not an Ajax-Enabled project, you canmodify the web.config and add reference to the AjaxControlToolkit.dll.

By the way, Javascript intellisense is support by VS2008.

Hope this help.

Best regards,

Jonathan


Thanks for your respnose! I already have all those things installed. I guess I should have given more background. I am trying to create the controls in my c# page_load method. When I dynamically create the controls Intellisense doesn't work, so I've been using Reflector to see what methods are available on the different classes. It doesn't really get annoying until you have to drill down through the class hierarchy to find out what a property is called. My code compiles and runs, but it's difficult to develop with the AJAX Control Toolkit if intellisense doesn't work. I would like to know how to get the intellisense for the control toolkit to work.

Thanks,

Jerry

Dynamic content made easy [How to: Use the new dynamic population support for Toolkit cont

Since the feature request has come up so many times here and since we now support the relevant scenario in the new 60914 release of the Toolkit, I've just blogged a little example of dynamically populating the content of a popup control (HoverMenu, ModalPopup, or PopupControl) as it's being displayed. You can find the blog post here:

http://blogs.msdn.com/delay/archive/2006/09/19/762609.aspx

Hope this helps!

Hi David,

Thanks for this post. This does seem handy. However, what if the DataList in your example is programatically binded and we want it inside of an update panel? I modified your example to do this and I get an assertion failed error when I click my button to load the DataList. Any thoughts on how to accomplish this?

Thanks.

1<%@. Page Language="C#" %>2<%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit"3 TagPrefix="atlasToolkit" %>4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"5 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">67<script runat="server">8 [System.Web.Services.WebMethod]9 public string GetContent(string contextKey)10 {11 // Create a random color12 string color = (new Random()).Next(0xffffff).ToString("x6");13 // Use the style specified by the page author14 string style = contextKey;15 // Display the current time16 string time = DateTime.Now.ToLongTimeString();17 // Compose the content to return18 return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> ";19 }2021 protected void Button2_Click(object sender, EventArgs e)22 {23 DataList1.DataSourceID = "XmlDataSource1";24 DataList1.DataBind();25 }26</script>2728<html xmlns="http://www.w3.org/1999/xhtml">29<head id="Head1" runat="server">30 <title>Dynamic ModalPopup Demonstration</title>3132<%-- Style the page so it looks pretty --%>33 <style type="text/css">34 body { font-family:Verdana; font-size:10pt; }35 .background { background-color:Gray; }36 .popup { width:200px; padding:10px; background-color:White;37 border-style:solid; border-color:Black; border-width:2px;38 vertical-align: middle; text-align:center; }39 </style>40</head>41<body>42 <form id="form1" runat="server">4344<%-- Atlas pages need a ScriptManager --%>45 <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />4647<%-- A very simple data source to drive the demonstration --%>48 <asp:XmlDataSource ID="XmlDataSource1" runat="server">49 <Data>50 <items>51 <item style="font-weight:bold" />52 <item style="font-style:italic" />53 <item style="text-decoration:underline" />54 </items>55 </Data>56 </asp:XmlDataSource>57  <%-- A simple list of all the data items available --%>58 <atlas:UpdatePanel ID="UpdatePanel1" runat="server">59 <ContentTemplate>6061 <asp:DataList ID="DataList1" runat="server">6263 <HeaderTemplate>64 How would you like your dynamic content styled?65 </HeaderTemplate>6667 <ItemTemplate>68 • <asp:LinkButton ID="LinkButton" runat="server" Text='<%# Eval("style")%>' />6970<%-- The ModalPopupExtender, popping up Panel1 and dynamically populating Panel2 --%>71 <atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">72 <atlasToolkit:ModalPopupProperties73 TargetControlID="LinkButton" PopupControlID="Panel1" OkControlID="Button1"74 BackgroundCssClass="background" DynamicControlID="Panel2"75 DynamicContextKey='<%# Eval("style")%>' DynamicServiceMethod="GetContent" />76 </atlasToolkit:ModalPopupExtender>77 </ItemTemplate>7879 </asp:DataList>80 <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />81 </ContentTemplate>82 </atlas:UpdatePanel>8384<%-- All ModalPopups share the same popup --%>85 <asp:Panel ID="Panel1" runat="server" CssClass="popup" style="display:none;">86 <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p>87 <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>88 </asp:Panel>8990 </form>91</body>92</html>

Can this be done in a Web User Control for example? How?

Cheers


To avoid the asserts in the scenario above, just use the recommended "empty extender in the page body" workaround. Specifically, add the following line below Button2:

<atlasToolkit:ModalPopupExtender ID="PlaceholderModalPopupExtender" runat="server" />

Regarding doing this in a Web User Control, I expect it should work fine. What trouble are you having?


David,

I cannot get it to call the method in the web user control.

I have created a seprate thread:http://forums.asp.net/thread/1404652.aspx

Ziax


FYI: I've posted a new blog entry outlining the steps to update the sample to the new ASP.NET AJAX style used by Beta 1/2:

http://blogs.msdn.com/delay/archive/2006/11/17/dynamic-content-made-easy-redux-how-to-use-the-new-dynamic-population-support-for-toolkit-controls.aspx


First, thanks for the code. I have another question :What if I want to have DataGrid inside Panel1 which value depends on DynamicContextKey from ModalPopup

 <asp:Panel ID="Panel1" runat="server" CssClass="popup" style="display:none;"> <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p> <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>

<

asp:DataGridID="dgYesNo"runat="server"></asp:DataGrid> </asp:Panel>


You might consider something like this:http://weblogs.asp.net/scottgu/archive/2006/10/22/Tip_2F00_Trick_3A00_-Cool-UI-Templating-Technique-to-use-with-ASP.NET-AJAX-for-non_2D00_UpdatePanel-scenarios.aspx
what if I have an dropdownlist, how can I populate it?
what if I have a dropdownlist, how can I populate it?

Dynamic Content into ModalPopup

I've just started playing with the AJAX Toolkit. One thing I am stuck on, ishow to get dynamic content into the controls that are in the modalPopup PopupControlID?

A very simple example:

There is a textbox and a button. When you enter text then click the button, a modal popup appears saying "You entered..." and whatever you typed. Is there a way to do this in the codebehind? It dosen't seem like the button click event is firing since it is the "TargetControlID" of the modalPopup.

Thanks

Have a look at this bloghttp://blogs.msdn.com/delay/archive/2006/09/19/762609.aspx. I did this my self the other day but I did it a slightly different way, when I get back to work I will post the code.


Thank you for the reply. I took a look at the article, and there is some good information there. I actually ended up accomplishing what I need by assigning the "TargetControlID" to a bogus control (using this example, it's a bummer this property cannot be null or empty) and using the ModalPopupExtender1.Show() method. This seems to be doing the trick. This way, I can use any event or condition to pop the ModalPopup, and all of the controls (including the panel i am using as the "PopupControlID". are accessable at design.

So, i have a button, on the click event i create all of the controls i need and add them to the panel, then call ModalPopup1.Show() and there it is.

Now the problem i'm facing is getting values from the ModalPopup back into the main screen. For example, if I have a textbox in the ModalPopup, when the user clicks OK on the modalpopup, how to i get that value? Remember that the TextBox and it's properties were generated at runtime, so after postback, they wont' exist. I guess I could try to use the Request.Form key values?


bortiquai:

I guess I could try to use the Request.Form key values?

This is a option.

Or you can use a HiddenField which will always be on the page to keep this value. The value of HiddenField can be set in onclick client side event handler of ok button.

Dynamic Animation

Hi threr;

I want create an show a dynamic animation(exactly like select tag window in this page) using AJAX Control Toolkit animation control. At frist, I dont know how can I create a dynamic animation. Second, I want to call the animation via an event instead of button click.

Hi nima_montazeri,

Check outthis post on how to dynamically create Animations. You can't cause an animation to be played in an event other than those it supports. There is a workaround you could try though. You can create a dynamic OnLoad animation in your event which will play as soon as your page is reloaded - you just have to be careful to clear it out before the next postback.

Thanks,
Ted

Monday, March 26, 2012

dyanamic creation of toolkit controls?

Hi,

Can we create ajax controls dynamically i.e. in javascript? For example, I wish to create a tab control dynamically? Can we do that?

--jon

You can definitely create your AJAX controls/behaviors using the $create() statements (most likely called/hooked-up from the application init function). You should create a few Ajax controls declaratively in the page and then view the source it outputs to get an idea of the syntax needed.

Dual slider implemetation in ajax

Hiii

i have just started using the ajax toolkit. i have used the slider extender. But now my requirement is that i need to have a slider

with has got two handles.. how can i do that and how can i handle the text changed event for each of the handles.. Does ajax toolkit

has such an implementation..

Its very urgent

This came up before but it got rejected by the dev team. It looks like someone has gotten it working though:http://www.dimebrain.com/2007/07/a-dual-slider-f.html


Hello,

Just wanted to add that the example I presented earlier doesn't work with the latest version of the Toolkit, unfortunately. I'm using a different solution now, you can find it here:http://www.dimebrain.com/2007/11/another-dual-sl.html, but keep in mind that it's using another framework. ASP.NET AJAX is only used to load the scripts into the manager.



S i have worked out your sample in that web site. It works well in a sample project. But it doesnt work in my original project. When i ll add inside the <table><tr><td> .... </> tag it doesnt work . Y?

DropShadowExtender; Showing up on Top

I am using VS2008 and the included AJAX Control ToolKit

I have a master page that includes the scriptmanager and a panel with the DropShadowExtender

I have added a content page, that has a panel with a DropShadowExtender.

When the page displays, the 2nd DropShadow, goes UP, and displays on the top of the box. Basically an UPShadowExtender.

Any ideas to correct?

I have noticed a similar situation in the past if I am using tables or panels (and I would presume divs as well since panels are rendered as divs) I am trying to recall exactly what solved the issue but I do recall it had something to do with the width of each of the elements. I beleive if I had a table and had the extender to another control within that table, and the content in that table forced the outter table (or panel) to expand, I noticed that the dropshadow extender would push upwards.

Basically, what Im trying to say is, check your table, div, panel widths and heights. Make sure the content has ample room.


Hi,

Thank you for your post!

Create a simple repro for this issue if you can,and please post up the whole code of the repro.

Anyway, I agree withjgilmore. you should do moretroubleshoot wok and then you can provide us with more valuable information.

Best Regards,

dropshadowextender visible when its targetcontrol is not

Hi

I have read thsi post which addresses this problem

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

I have downloaded the latest version of the toolkit and my dropshadowextender is visible when the control it's shadowing is not visible.

How can i modify the javsacript in DropShadowBehavior.js in my current dll. Presumably its embedded.

Thanks very much

andrea

Hi Andrea,

You can just edit the *.js files. You have torebuild the project for the changes to take effect though.

Thanks,
Ted
The fix mentioned in the above thread is known to work under at least some circumstances. Could you please post a simple sample demonstrating how it doesn't work in your scenario? That'll help us make a fix. Thanks.
thanks very much

DropShadowExtender and positioning

Hello, I just started messing around with the toolkit and started with the DropShadowExtender. I can't, for the life of me, get it to work with various positioning styles. For instance, consider the following simple example:

<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.overall
{
position: relative;
left: 10px;
top: 10px;
;
height: 500px;
background-color: Silver;
}
.above
{
position: absolute;
margin-left: 10px;
margin-top: 10px;
z-index: 2;
width: 200px;
height: 200px;
background-color: Green;
}
.below
{
position: absolute;
top: 0px;
left: 0px;
width: 300px;
height: 200px;
z-index: 1;
background-color: Blue;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />

<div class="overall">
<asp:Panel ID="above" runat="server" CssClass="above">
Here's some text in a box.</asp:Panel>
<cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="above" Opacity=".5" Rounded="true" TrackPosition="true">
</cc1:DropShadowExtender>
<div class="below">This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... </div>
</div>

</form>
</body>
</html>

What could I possibly be doing wrong? These utilities must be able to work with positioned elements, no? Any insight is much appreciated. Thanks!

Anyone? Anyone? Bueller?

I'd really appreciate any insight on this... Looking through the forums, it appears this extender may simply not work with positioned elements. That's a huge disappointment, but I can live with ditching it if it got a firm denial anywhere. However, it seems whenever anyone raises this issue it simply gets ignored. If this extender doesn't work with positioned elements, it would be great to have a release note or known issue added to the documentation to avoid anyone wasting so much time to find out if it works or there is a workaround. Can anyone else at least copy and paste this code and build a project really quickly just to verify that this is not working? As you can see, it's not an enormously complicated bit of CSS, so I'd like to know if anyone is actually using this extender and seeing it work in any sort of good real-world environments. Heck, I'd like to see if anyone can even get it to work in a testing environment. Thanks...


Can someone at least verify that this is not an isolated issue?

Does this control work, or what? Can NOBODY show a working example with positioned elements? Please? Is this a sore subject, am I missing a FAQ somewhere, or what - I find it crazy that nobody can even take the time to respond to this thread...


Hi Tucker973,

As we know DropShadowExtender works based on complex JS and CSS code, so it is not recommanded to attach many CSS. Based on my experience, I suggest that you should put it into a container and then use css to control its position instead of doing this on DropShadowExtender directly.Here is the working sample.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style type="text/css"> .dropShadowPanel { width:300px; background-color:#5377A9; color:white; font-weight:bold; } .containerPanel { margin-left:200px; margin-top:200px; } </style></head><body> <form id="form2" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:Panel ID="container" runat="server" CssClass="containerPanel"> <asp:Panel ID="Panel1" runat="server" CssClass="dropShadowPanel"> <div style="padding:10px"> First Name: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> Last Name: <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /> </div> </asp:Panel> <ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" BehaviorID="DropShadowBehavior1" TargetControlID="Panel1" Width="5" Rounded="true" Radius="6" Opacity=".75" TrackPosition="true" /> </asp:Panel> </form></body></html>

Best regards,

Jonathan


Interesting, thanks for the reply. It's working a bit better, but I'm still having an issue with the 'shadow' div getting placed way far away regardless of the "width" setting. I'll continue to mess with it though, this is definitely a step in the right direction. Thanks again.

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style type="text/css"> .overall { position: relative; left: 10px; top: 10px; ; height: 500px; background-color: Silver; } .above { position: absolute; margin-left: 50px; margin-top: 50px; z-index: 2; } .aboveinside { width: 200px; height: 200px; background-color: Green; } .below { position: absolute; top: 0px; left: 0px; width: 300px; height: 200px; z-index: 1; background-color: Blue; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div class="overall"> <div class="above"> <asp:Panel ID="above" runat="server" CssClass="aboveinside"> Here's some text in a box.</asp:Panel> </div> <cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="above" Width="1" Opacity=".5" Rounded="true" TrackPosition="true"> </cc1:DropShadowExtender> <div class="below">This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... </div> </div> </form></body></html>


Hi Tucker973,

<%@. Page Language="C#" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <style type="text/css"> .overall {left: 10px; top: 10px; ; height: 500px; background-color: Silver; } .above { position: absolute; margin-left: 50px; margin-top: 50px; z-index: 2; } .aboveinside { width:300px; background-color:#5377A9; color:white; font-weight:bold; } .below { margin-top: 10px; left: 0px; width: 300px; height: 200px; z-index: 1; background-color: Blue; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div class="overall"> <asp:Panel ID="above" runat="server" CssClass="aboveinside"><div style="padding:10px"> Here's some text in a box.</div> </asp:Panel> <cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="above"Width="5" Opacity=".5" Rounded="true" TrackPosition="true"Radius="6"> </cc1:DropShadowExtender> <div class="below">This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... This is some text underneath... </div> </div> </form></body></html>

Best regards,

Jonathan

Saturday, March 24, 2012

Dropdownlist with non-selectable ListItems

Is it possible to use one of the toolkit controls to create a Dropdownlist containing ListItems that are selectable andnon-selectable? (i.e. hovering your mouse over thenon-selectable items doesn't highlight them and clicking on them does nothing - they are just there to group ListItems together).

Consider these 8 ListItems in a DropdownList:

-- Fruit --

Apple

Orange

Banana

-- Vegetables --

Carrot

Onion

Garlic

Using this hypothetical control, the ListItems "--Fruit--" and "--Vegetables--" would benon-selectable (and just there for grouping). All other listitems would be selectable.

How can I do this?

Hi,

Currently, this feature isn't available, you may submit a feature requesthere if you don't plan to implement it yourself.

Dropdownlist with non-selectable items

Hi all,

I've been using AJAX and the Toolkit. I don't know much about authoring my own controls, so I'll need a lot of help here. Basically what I want is a dropdownlist where some of the items in the list are non-selectable. I can then use the non-selectable items to group selectable items together. For example:

Imagine the following items in a Dropdownlist:

-- Fruit --

Apple

Orange

Banana

-- Vegetables --

Carrot

Onion

Garlic

I want the items "Fruit" and "Vegetables" should be non-selectable. I could always do this with two cascading dropdown lists but this is a more user-friendly solution (less controls, less clicks, etc). It was also requested by my clients.

You can check ,

DropDownList.SelectedIndex property for perticauler position value.

If it is --Fruit-- or --Vegetables-- try to re-set index of dropdownlist.


I suggested that to the clients butthey want these items to be static - i.e. don't even give the user the chance to select them.

In other words, when you hover your mouse over --Fruit-- or --Vegetable-- ListItems, theyshouldn'tbe highlighted or selectable at all. If the user tries to click on one of them, the DropDownList should just continue to be expanded as if nothing happened.

Wednesday, March 21, 2012

DropDownExtender!

The Toolkit Example is quite simple, my scenario is I have a DropDownList which is binded to a data source! How can I add the triggers for 50+ ListItems of my DropDown?

<Triggers><asp:AsyncPostBackTriggerControlID="Option1"EventName="Click"/>

<asp:AsyncPostBackTriggerControlID="Option2"EventName="Click"/>

</Triggers>

I want to basically navigate the dropdownlist using my arrow keys on the keyboard and I have an imagePanel whose Image changes depending upon what item selection on the dropDownlist, right now if I click on the DropDownList I am able to update the ImagePanel, but I want to do this using the arrow keys...

Youre not going to be able to do this in any easy way. It is possible but if you want to make it happen you have to pump out a heap of javascript. If you still want to let me know and Ill try and point you in the right direction.

DropDownExtender offset since 10201

When upgrading my toolkit dll to the latest version, all my dropdownextenders seem to render with 20 pixels margin to the left side. It's only the "dropdownbox" surrounding the textlabel: the dropdownlist itself is where it should be. Anyone else experiencing this problem? It might have to do something with my CSS, but it worked before. I've already copied the CSS from the example website, that didn't fix it (though it was different from the file I had)

Isn't anyone experiencing these problems? It probably has something to do with relative/absolute positioning or something. I wonder what changed since last release cause I didn't experience these problems before.

Which CSS class handled the dropdown position?