Creating an Ajax Toolbox control using vb.net on the server

I am brand new to Ajax and I'm trying to figure out how to insert an Ajax toolkit HoverMenu control using vb.net on the server.  Is there any vb.net sample code available that demonstrates how to create controls from the Ajax Toolbox?  I'm not sure of (among other things) what namespaces need to be imported.  As I said, I'm brand new to this and need help getting started.

Many thanks.

Sheldon

0
Sheldon
8/20/2007 5:32:38 PM
asp.net.ajax_control_toolkit 17816 articles. 1 followers. Follow

6 Replies
1180 Views

Similar Articles

[PageSpeed] 22
Get it on Google Play
Get it on Apple App Store

 Hi Sheldon,

I made this sample which create hoverMenuExtender according to your requirements, please try it.

 

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim he As AjaxControlToolkit.HoverMenuExtender = New AjaxControlToolkit.HoverMenuExtender()
        Me.form1.Controls.Add(he)
        he.TargetControlID = TextBox1.ID
        he.PopupControlID = Panel1.ID
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        
        <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
            <asp:LinkButton ID="LinkButton2" runat="server">LinkButton</asp:LinkButton>
            <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
            <asp:LinkButton ID="LinkButton3" runat="server">LinkButton</asp:LinkButton>
            <asp:LinkButton ID="LinkButton4" runat="server">LinkButton</asp:LinkButton></asp:Panel>
    </div>
    </form>
</body>
</html>
  
0
Raymond
8/23/2007 8:09:33 AM

Thanks for your help, Raymond.  Much appreciated.

If I may get a little more detailed, the real-life problem I am facing is that the controls to which I want to append hover menus are themselves dynamically created hyperlinks:

<a id="Task<%=rTask("TaskID") %>" href="taskDetail.aspx?TaskID=<%=rTask("TaskID") %>"><%=rTask("TaskName")%></a>

When I run the script, similar to yours, I get an error on "me.form1.controls.Add(hmenu)":  "A control with ID 'Task268' cannot be found".

What I really need to know is, how can I assign the HoverMenu's TargetControlID to a dynamically generated control whose ID I do not know at design time?

Thanks again.

Sheldon 

0
Sheldon
8/23/2007 4:10:44 PM

Sheldon Penner:
<a id="Task<%=rTask("TaskID") %>" href="taskDetail.aspx?TaskID=<%=rTask("TaskID") %>"><%=rTask("TaskName")%></a>
 

This isn't a server control, and can't be used as Target.

You may create it like this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim he As AjaxControlToolkit.HoverMenuExtender = New AjaxControlToolkit.HoverMenuExtender()
        Me.form1.Controls.Add(he)
       
        Dim hl As New HyperLink()
        Me.form1.Controls.Add(hl)
        hl.ID = "The value of TaskID"
        hl.Text = "dynamic hyper link"
        hl.NavigateUrl = "..."
       
        Dim pnl As Panel = New Panel()
        Me.form1.Controls.Add(pnl)
        pnl.ID = "pnlPop"
        Dim item As LinkButton = New LinkButton()
        pnl.Controls.Add(item)
        item.Text = DateTime.Now.ToString()
        he.TargetControlID = hl.ID
        he.PopupControlID = pnl.ID
    End Sub

 

If the hyperLink is in a databound control(like gridView), you may use these codes in RowDataBound event hander of the GridView.

0
Raymond
8/24/2007 3:42:35 AM

Thanks, Raymond.  I spent a few hours today mucking around with your code and a number of variations on it, and I believe I'm starting to catch on. 

I had been trying to upgrade a page that used a lot of "Response.Write"s to create an outline based on the data from my database.  I can see that that approach is not tenable in the brave new world of ASP.Net AJAX, so I have started experimenting with the Treeview control.  New Problem:  the TreeNode object does not have an ID property.  Soooo... Is there any way I can use use hover menus in conjunction with treeview nodes?  If not (and I think not), do you have any suggestions how I might create an outline where each item has its own hover menu?

 

0
Sheldon
8/25/2007 1:27:47 AM

I agree that this can't be achieved directly.

You may try this approach:

1. Wrap node's text in a div

2. set hovermenu's target to the div when mouse is on a div

 

Like this:

 

<%@ 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">

protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
TreeNode tn = new TreeNode();
TreeView1.Nodes.Add(tn);
tn.Text = "<div onmouseover='setTarget(this);'>" + "TreeViewItem " + i.ToString() + "</div>";
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function setTarget(target)
{
var hme = $find("hme");
hme._hoverBehavior.set_hoverElement(target);
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>
<ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" BehaviorID="hme" PopupControlID="Panel1" runat="server" TargetControlID="LinkButton1">
</ajaxToolkit:HoverMenuExtender>
<asp:TreeView ID="TreeView1" runat="server">
</asp:TreeView>
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
Menu<br />
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton2" runat="server">LinkButton</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton3" runat="server">LinkButton</asp:LinkButton></asp:Panel>
</form>
</body>
</html>
  
0
Raymond
8/27/2007 2:52:21 AM

Sorry it's taken me so long to respond to your suggestion. 

 I tried your code and find that it behaves erratically.  When the page is first loaded, hover menus do not appear at all.  However, if I click on one of the treenodes, since there is nothing in the OnLoad code to check for Postback, more lines are added to to the treeview and this time the first node does have a hover menu.  But only the first node and only under these circumstances.

 Your use of "BehaviorID" is something I am unfamiliar with.

Meanwhile, I have acquired a third party treeview control that has built in popup menus and other features that I will find useful.

Thanks again for all your help.

Sheldon

0
Sheldon
9/3/2007 4:25:57 PM
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

How to Create Web Server Control in VB.Net
I am developing a "User Authentication" Web Server Control which will consist of a Web User Control (Header and Footer Custom Control), a web-control which will display a username, password text box and database dropdown along with a Login button, and all code to authenticate a user. This is something I want to be able to easily drop into any project I wish. I have created an ASP.NET Web Application entitled "UserAuthentication" but want to make sure I am going in the right direction. How should I create this "WEB SERVER CONTROL" for this Login/User Authentication in VB.Net...

Issue using control created in VS.net 2003 in VS.net 2002
I have a friend that has an issue using my asp.net C# custom control in Visual Studio.net 2002 that I have compiled under Visual Studio.net 2003. I never did test it with that version, but I was under the impression that it should still work as long as you don't use any features specific to the 1.1 framework (which I really don't think I did). My guess now is that this is correct, but only when using 2002 controls in 2003. I have searched the web, these forums, and MSDN for the last 30 minutes with no real answer. The guy that runs MetaBuilders (http://www.metabuilders.com/Faq.aspx) tell...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

VB.NET Codebehind Code to Update SQL Server 2005 Using SQLDataSource Control?
Hi, I am a newbie in using ASP.NET 2.0 and ADO.NET.  I wrote a hangman game and want to record statistics at the end of each game.  I will create and update records in the database for each authenticated user as well as a record for the Anonymous, unauthenticated user.  After a win or loss has occurred, I want to programmatically use the SQLDataSource control to increment the statistics counters for the appropriate record in the database (note I don't want to show anything or get user input for this function). I need a VB.NET codebehind example that will show me how I sho...

VB.NET
All, This is probably a much harder question than what should go in the "Getting Started" forum, but I am new and don't know where to put it. Anyways, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and download a file no problem. My issues come when I try to use the same class with the same commands to access an FTP server on a UNIX box. I can connect and login just fine, but after that all my commands come back "500 'PWD': command not understood.". This is fo...

ajax.net controls used in custom composite controls?
I am creating an events calendar that uses the accordion to display the events for the selected day.  The problem I'm having is that the accordion is not responding to any client side events.  I would really like to find a good "How to" article for building composite controls that incorporate an ajax.net control like the accordion....

How to use MS Chart Control in vb with vb.net
Hai Everybody, I want to display the my timesheet data in chart. So I used to MSChart.ocx control in asp.net. Is it possible to use that control. If No plz tell me the suggestion. Regards Somu I would suggest you to make chart using GDI+ name spaces in .Net For example see article @ http://www.dotnetbips.com/displayarticle.aspx?id=119 And also you could find the code related to charts at gotdotnet Hope these helps!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

how can i assign a dataBinding value to a control that i'm creating at run-time?
how can i assign a dataBinding value to a control that i'm creating at run-time? i just want to know the syntax in the missing place:   Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn Select Case (_Type)Case ListItemType.Item Dim newLinkButton As LinkButton = New LinkButton() newLinkButton.CommandName = "Select" newLinkButton.Text = ________the missing place_____________ container.Controls.Add(newLinkButton) Exit Select End Select End Sub you should be able to adapt the technique in this article: htt...

How can I use c# 's project web server control on a vb.net project....Help Please
Hi       I am using a server control in a C# project in an aspx file. It works fine when I use that in that same c# project. But when I import the assembly into a vb project and place the control on the page. Its giving me a System.NullReferenceException: Object reference not set to an instance of an object. error message. Please help me with it, I cant even debug it as soon as I land on the aspx page this error appears. Please help me in getting through with this message. I have spend two days working on it. Its giving me an error message on this line this.t...

how can i write this line using vb.net : container.dataitem ?.... in vb.net its not working
Dim container As GridView = CType(newLinkButton.NamingContainer, GridView) Dim dataValue As Object = DataBinder.Eval(container.dataitem, _ColName)   _ColName its just a string a name of the field in my database   This is Vb.Net code man what you want? You can convert any format from this link http://www.developerfusion.com/tools/convert/vb-to-csharp/  If this post is answer of your question then don't forgot to Click Mark As Answer...

Web resources about - Creating an Ajax Toolbox control using vb.net on the server - asp.net.ajax_control_toolkit

Londonistan: How Britain is Creating a Terror State Within - Wikipedia, the free encyclopedia
The book encompasses a critique of multiculturalism , alleged weak policing, cultural relativism , and what Phillips calls a 'victim culture'. ...

Facebook’s Matt Kelly Describes Process Of Creating Plugin For WordPress
The plugin for WordPress launched by Facebook in June has been downloaded more than 180,000 times, and Engineer, Developer Relations Matt Kelly ...

Creating Online Ads that Drive Brand Awareness
New research shows how the creative elements of online ads impact brand awareness.

Bug - Creating a Video.Watches Action stopped working - Facebook-Entwickler
Since today executing a POST on a me/video.wacthes endpoints no longer works, it was working around 10 hours ago since then the call always returns ...

Facebook Creating Fourth-Party Privacy Rules for Facebook Connect Widget & Plugin Developers
In a recently-written post on the Facebook Developers Wiki, Facebook had added new rules for information sharing between websites that have implemented ...

The Obama campaign won by creating their own Facebook, with unique features for political campaigns.
... seen as too dangerous to nominate someone who is so thoroughly narcissistic, arrogant and dishonest. The Obama campaign won basically by creating ...

Creating A Great Startup Culture
... with any Bay Area startup these days (ping pong, beer on tap, catered lunches and Macbook Airs) – though these things are, of course, Creating ...

WIRED Creating the Nebula for iPad on the iTunes App Store
Get WIRED Creating the Nebula on the App Store. See screenshots and ratings, and read customer reviews.

Nets of freedom creating mesh networks 03.07.2013 - Flickr - Photo Sharing!
Explore Strelka Institute photo's photos on Flickr. Strelka Institute photo has uploaded 14526 photos to Flickr.

Creating the incorrigible Cartman - YouTube
"South Park" creators Trey Parker and Matt Stone were big fans of "All in the Family," a 1970s CBS sitcom. Perhaps this is why their most incorrigible ...

Resources last updated: 1/4/2016 8:47:47 AM