473,657 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding selectable ASP options to Custom Web Controls

Hello,

One thing I am looking to do is to create a couple of different custom
Web Controls that can give me added options when specifying them
in an ASP.NET page. For example:

<asp:RadioButto nList id=RadioButtonL ist1 runat="server">
<asp:ListItem myvalue1="x" myvalue2="y">It em 1</asp:ListItem>
<asp:ListItem myvalue1="a" myvalue2="b">It em 2</asp:ListItem>
<asp:ListItem myvalue1="g" myvalue2="h">It em 3</asp:ListItem>
</asp:RadioButton List>

What I did was to create a custom Web Control and created get/set statements
for myvalue1 and myvalue2. I actually placed the value of the DataTextField
into a HashTable so the value I was setting could be stored and retrieved
depending on the listItem and/or what was selected. I am having problems
getting
this to work. Am I concentrating on the right area to get this all to work?

Thanks,
Peter

Nov 19 '05 #1
3 1326
Hi Peter,

I think you're going to run into trouble because you're trying to make HTML
do something that it wasn't intended to do. Rather than mess with illegal
attributes, how about just separating the values with a pipe (|) or other
character and then parsing the selected value.

Here's some samble code in VB (VS 2005). Let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub RadioButtonList 1_SelectedIndex Changed _
(ByVal sender As Object, ByVal e As System.EventArg s)
Dim myvalue As String()
myvalue = Split(RadioButt onList1.Selecte dItem.Value, "|")
Label1.Text = "myvalue1=" & myvalue(0) & " : myvalue2=" & myvalue(1)
End Sub
</script>

<html>
<head runat="server">
<title>Multi List</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButto nList id="RadioButton List1" runat="server"
AutoPostBack="T rue"
OnSelectedIndex Changed="RadioB uttonList1_Sele ctedIndexChange d">
<asp:ListItem Value="x|y">Ite m 1</asp:ListItem>
<asp:ListItem Value="a|b">Ite m 2</asp:ListItem>
<asp:ListItem Value="g|h">Ite m 3</asp:ListItem>
</asp:RadioButton List><br />
&nbsp;<asp:Labe l ID="Label1" runat="server"> </asp:Label></div>
</form>
</body>
</html>

"Peter" <sp**@nospameri no.com> wrote in message
news:pP******** *************** *******@comcast .com...
Hello,

One thing I am looking to do is to create a couple of different custom
Web Controls that can give me added options when specifying them
in an ASP.NET page. For example:

<asp:RadioButto nList id=RadioButtonL ist1 runat="server">
<asp:ListItem myvalue1="x" myvalue2="y">It em 1</asp:ListItem>
<asp:ListItem myvalue1="a" myvalue2="b">It em 2</asp:ListItem>
<asp:ListItem myvalue1="g" myvalue2="h">It em 3</asp:ListItem>
</asp:RadioButton List>

What I did was to create a custom Web Control and created get/set
statements
for myvalue1 and myvalue2. I actually placed the value of the
DataTextField
into a HashTable so the value I was setting could be stored and retrieved
depending on the listItem and/or what was selected. I am having problems
getting
this to work. Am I concentrating on the right area to get this all to
work?

Thanks,
Peter

Nov 19 '05 #2
Thanks for very much for the reply Ken. Yes, I was originally thinking in
the
direction you mentioned but there are multiple components where I need to
store these dual values and one of them is a textbox. However now that
I know this is not doable I will go with the strategy of populating the
DataValueField.
As for the textboxes I can use the tooltip field. I can write a function to
sort
it all out for me.

BTW, the reason I wanted the more elegant solution is that I was hoping once
I got this all together was to have non-technical type people to build these
scripts
as needed because they seem to make almost daily changes. However if I spell
it
out for them it hopefully won't be too bad...

Thanks,
Peter
"Ken Cox [Microsoft MVP]" <BA**********@h otmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Peter,

I think you're going to run into trouble because you're trying to make
HTML do something that it wasn't intended to do. Rather than mess with
illegal attributes, how about just separating the values with a pipe (|)
or other character and then parsing the selected value.

Here's some samble code in VB (VS 2005). Let us know if it helps?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>
<script runat="server">
Protected Sub RadioButtonList 1_SelectedIndex Changed _
(ByVal sender As Object, ByVal e As System.EventArg s)
Dim myvalue As String()
myvalue = Split(RadioButt onList1.Selecte dItem.Value, "|")
Label1.Text = "myvalue1=" & myvalue(0) & " : myvalue2=" &
myvalue(1)
End Sub
</script>

<html>
<head runat="server">
<title>Multi List</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButto nList id="RadioButton List1" runat="server"
AutoPostBack="T rue"
OnSelectedIndex Changed="RadioB uttonList1_Sele ctedIndexChange d">
<asp:ListItem Value="x|y">Ite m 1</asp:ListItem>
<asp:ListItem Value="a|b">Ite m 2</asp:ListItem>
<asp:ListItem Value="g|h">Ite m 3</asp:ListItem>
</asp:RadioButton List><br />
&nbsp;<asp:Labe l ID="Label1" runat="server"> </asp:Label></div>
</form>
</body>
</html>

"Peter" <sp**@nospameri no.com> wrote in message
news:pP******** *************** *******@comcast .com...
Hello,

One thing I am looking to do is to create a couple of different custom
Web Controls that can give me added options when specifying them
in an ASP.NET page. For example:

<asp:RadioButto nList id=RadioButtonL ist1 runat="server">
<asp:ListItem myvalue1="x" myvalue2="y">It em 1</asp:ListItem>
<asp:ListItem myvalue1="a" myvalue2="b">It em 2</asp:ListItem>
<asp:ListItem myvalue1="g" myvalue2="h">It em 3</asp:ListItem>
</asp:RadioButton List>

What I did was to create a custom Web Control and created get/set
statements
for myvalue1 and myvalue2. I actually placed the value of the
DataTextField
into a HashTable so the value I was setting could be stored and retrieved
depending on the listItem and/or what was selected. I am having problems
getting
this to work. Am I concentrating on the right area to get this all to
work?

Thanks,
Peter


Nov 19 '05 #3
Hi Peter,

Another approach would be to use a set of parallel hidden fields to hold the
extra values. You would have to match them up to the visible field in some
way, perhaps through a naming convention.

Ken

"Peter" <sp**@nospameri no.com> wrote in message
news:f-*************** *************** @comcast.com...
Thanks for very much for the reply Ken. Yes, I was originally thinking in
the
direction you mentioned but there are multiple components where I need to
store these dual values and one of them is a textbox. However now that
I know this is not doable I will go with the strategy of populating the
DataValueField.
As for the textboxes I can use the tooltip field. I can write a function
to sort
it all out for me.

BTW, the reason I wanted the more elegant solution is that I was hoping
once
I got this all together was to have non-technical type people to build
these scripts
as needed because they seem to make almost daily changes. However if I
spell it
out for them it hopefully won't be too bad...

Thanks,
Peter

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3720
by: avivgur | last post by:
Hello, I am writing a program in Visual C# and I have encountered a problem. In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user...
5
5037
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the CurrentUICulture to what's specified in the querystring. Since I want to allow UICulture auto detecting, I add UICulture = "auto" to page directive on each page.
3
2339
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
3
1485
by: MikeY | last post by:
Hi everyone, I'm trying to figure out, on my windows form, of what is the best way to add various custom controls at various times during run-time. The problem is that they will need to be in the same spot as each other, depending on what is being called at that particular time by the user. I have been trying to use Inherited user controls, but I am not able, and/or don't know how to retrieve the data from my Inherited user control. If...
3
1990
by: Kannan | last post by:
Hi, I am trying to created Outloook Add-in Com in outlook using C#. I have seen this URL for developing this sample http://support.microsoft.com/?kbid=302901 When I executed this program it created new custom button called "My Custom Button" in the Outlook menu bar. But when I tried to create one more button called "Forward Mail" (code is
11
18111
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with ListView columns so it should be doable, thanks
6
11068
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
12
1594
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a custom Page object which is derived from the base Page object. We also have custom controls that derive from a base class that performs custom drawing and inherits from our own IOurControl interface. There is also a special caching layer in the mix...
4
17905
by: jack | last post by:
Hi, Consider the following handler: protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e) { GridViewRow row = e.Row; if (row.RowType != DataControlRowType.DataRow) return;
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
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 we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.