|
-
February 5th, 2010, 04:31 AM
#1
[RESOLVED] Html decode?
I am importing an array of names from the db and for each element in the array I am creating a radiobutton. The radiobutton's ID corresponds to the array name. Certain names contain special characters and are therefore written in ASCII HTML character code. I later perform some operations to determine which radiobutton has been selected but then the radiobuttons with the HTML ID are not recognized. I tried inserting the following to ensure the ID stays in HTML character code form throughout the code but it doesnt seem to work:
Code:
selectedRbtnID = Server.HtmlDecode(radiobutton.ID);
Is there another way to tackle this?
-
February 5th, 2010, 05:42 AM
#2
Re: Html decode?
Hi,
I would suggest having a different identifier. If possible try to go for a numeric value or a combination of simple letters and numbers. If you can change the database and assign the relevant records unique identifiers do that. I would also add that the identifiers don't need to come from the database. You can generate them in your code after you retrieve the data. This can be as simple as starting with an initial value and just incremeting and assigning it as an id.
-
February 5th, 2010, 10:05 AM
#3
Re: Html decode?
try this...
Code:
selectedRbtnID = HttpUtility.UrlDecode(radiobutton.ID);
you will need to add a reference to the System.Web namespace(if you don't already have it).
I tested with this, and it converted it correctly...
Code:
string test = HttpUtility.UrlDecode("hello%20world");
// Output
// "hello world"
===============================
My Blog
-
February 5th, 2010, 10:12 AM
#4
Re: Html decode?
 Originally Posted by eclipsed4utoo
try this...
Code:
selectedRbtnID = HttpUtility.UrlDecode(radiobutton.ID);
you will need to add a reference to the System.Web namespace(if you don't already have it).
I tested with this, and it converted it correctly...
Code:
string test = HttpUtility.UrlDecode("hello%20world");
// Output
// "hello world"
Good point. I would still prefer to have an identifier that doesn't include spaces or any special characters...
-
February 5th, 2010, 05:47 PM
#5
Re: Html decode?
and how about not decoding this string at all but putting it in the Tag property and give the radiobuttons other names
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
February 6th, 2010, 10:29 PM
#6
Re: Html decode?
If it is the id attribute of the buttons you are talking about then I would also suggest used a different identifier. If you have an auto incrementer on the rows in the database, this would be an ideal choice.
Something like id="button_1234"
you could also do it with javascript? I'm don't know the specifics of you application, but i know that you can add arbitrary data to any element using the .data function in JQuery.
An attached event handler could then make the correct request once the button is selected.
-
February 8th, 2010, 04:17 AM
#7
Re: Html decode?
Thank you very much, now it works!
I took Jonlist's advice and used "_" in the ID instead of "." and then used the following to decode the ID:
Code:
rbtnSkill.ID = HttpUtility.HtmlDecode(criterium[i].Skill) + "_" + eNum;
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|