473,480 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Button control - ASP.NET - VB

3 New Member
Hey, I'm still very new to ASP and am looking for some help to manage some dynamic content. I created a little diagram of what I need so that you have an overall picture of where this fits in.



Basically I have a set of users (grabbed from a database), For each user one of those little panels is created (I showed 2). Each panel consists of a button to delete that user. A list box that has some values, a button to add to the listbox, one to delete from the list box and a third that does something in the "STUFF" section.

Now, I obviously don't know how many of these users there will be so I don't know how many buttons there should and I need to do it dynamically.

I've tried the following code for each user.
Expand|Select|Wrap|Line Numbers
  1. <%
  2.       DeleteBtn.Text="Delete " & dataREADER.Item("UserName")
  3.       DeleteBtn.attributes.add("commandargument","runDelete")
  4.       %>
  5.                         <asp:button id="DeleteBtn" runat="server" oncommand="rundelete"></asp:button>
  6.  
Unfortunately the commandargument doesn't seem to be coming through. I've tried changing the ID, the text etc but none of it seems to persist after I've posted the page (clicked the button).

Is there something easy that I can change in my code to make it work this way or will I need to redesign it? If I need to re-design it, how would I do it?
Jan 31 '08 #1
4 2054
Hatterson
3 New Member
So I guess I've made a little progress but still need help and google is turning up nothing.

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" %>
  2. <script runat="server">
  3.  
  4. sub Page_Load()
  5.  
  6.   BtnMessage = new Button()
  7.   BtnMessage.ID = "BtnDelete"
  8.   handler  = New CommandEventHandler(addressof runContentDelete)
  9.   addhandler BtnMessage.Command, handler
  10.   ButtonPlaceHolder.Controls.Add(BtnMessage)
  11.  
  12. end sub
  13.  
  14. </script>
  15.  
  16. <html>
  17.  
  18. <%while dataREADER.read()%>
  19.    <asp:PlaceHolder id="ButtonPlaceHolder" runat="server"></asp:placeholder>
  20. <%end while%>
  21.  
  22. </html>
  23.  
This simply places a button for each of the placeholders, which is kinda what I want, however I still can't tell the buttons apart in runContentDelete().

If I add this to the while loop
Expand|Select|Wrap|Line Numbers
  1. <%dim c as button
  2. while dataREADER.read()
  3. c = ButtonPlaceHolder.Controls(0)
  4. c.text = dataREADER.Item("UserName")
  5. %>
  6.    <asp:PlaceHolder id="ButtonPlaceHolder" runat="server"></asp:placeholder>
  7. <%end while%>
  8.  
Each of the buttons displays nicely (with the users name) but in runContentDelete, sender.text is nothing. It seems that the stuff isn't persisting through a post. .CommandName and .CommandArgument behave the same.
Jan 31 '08 #2
jhardman
3,406 Recognized Expert Specialist
one little question just to make sure I understand you, this is an ASP.NET project written in VB? Please confirm.

Jared
Feb 4 '08 #3
Hatterson
3 New Member
Yes, sorry I didn't say that before, ASP.NET/VB specifically I'm using Web Matrix as the IDE.
Feb 5 '08 #4
jhardman
3,406 Recognized Expert Specialist
I'm moving you over to the .NET forum. We are in the process of adding an ASP.NET forum, until then we are trying to keep these questions in the .NET forum rather than the ASP forum.

Jared
Feb 5 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6794
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
6
2899
by: MikeY | last post by:
Hi Everyone, Does anyone know where I can get my hands on a sample with source code of a simple dynamic button control in C# Windows form. I am looking for a sample that uses a class library...
5
19638
by: RA | last post by:
I have created a button dynamically; which has been added to a TableCell of a TableRow of a Table control. Is there a way to add onclick event which calls a procedure on the Server-side itself....
1
2145
by: Steve Booth | last post by:
I have a web form containing a button that when selected adds a user control to a place holder. The user control contains a button. The first time the user control is added the contained button...
3
1699
by: vodafone | last post by:
Hy all I've a little problem. I need to write a dynamic page that render control according to validation status return from previous control validation status. To be clear, I've page that...
3
13721
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
0
2219
by: Scott Roberts | last post by:
I always thought that the viewstate "keys" included the control ID. As long as the control IDs were unique, there shouldn't be any conflicts. Well, it appears that that may not be the case with...
1
4631
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
3461
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
4426
Frinavale
by: Frinavale | last post by:
I've created a ASP.NET control that displays a "book" of schedules. It dynamically displays scheduling times and allows the user to page through the schedules. It also lets the user edit the...
0
7051
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6915
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7097
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4493
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3003
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.