String Array written to and parsed from hidden web control
-
Hi there, I was wondering how I could go about writing an array of strings containing any character, into a hidden web control (textbox), and also as a parameter in a javascript function call. And not have it screw up the html on the rest of the page. Then be able to parse the one long string back into an array of strings, upon post back. The one long string can't have single quotes in it, cause it will screw up my javascrip parameter which wraps single quotes around the string. I would guess it would have to first write all the strings as one long one with some delimiter (that delimiter might already exist in the string and needs to be handled), and then convert that one big string into some kind of html compatible string not to screw up the rest of the html, or javascript parameter. Would some kind of XML work for sticking all strings into one big string? And UML or URL converter class work? Anyone have any ideas? I am hoping for some built in classes in the framework. There must be some kind of delimiter string creator class and html formatter class? I cant find any. Thanks in advance. Kris.
-
Hi there, I was wondering how I could go about writing an array of strings containing any character, into a hidden web control (textbox), and also as a parameter in a javascript function call. And not have it screw up the html on the rest of the page. Then be able to parse the one long string back into an array of strings, upon post back. The one long string can't have single quotes in it, cause it will screw up my javascrip parameter which wraps single quotes around the string. I would guess it would have to first write all the strings as one long one with some delimiter (that delimiter might already exist in the string and needs to be handled), and then convert that one big string into some kind of html compatible string not to screw up the rest of the html, or javascript parameter. Would some kind of XML work for sticking all strings into one big string? And UML or URL converter class work? Anyone have any ideas? I am hoping for some built in classes in the framework. There must be some kind of delimiter string creator class and html formatter class? I cant find any. Thanks in advance. Kris.
See the
HttpUtility
for anHtmlDecode
andHtmlEncode
method. You could encode each array element, then join then with a ','. When you need the array again, split on ',' and decode each element. Fortunately, javascript also has both an encode and decode method that you could use. Works out great.Microsoft MVP, Visual C# My Articles
-
See the
HttpUtility
for anHtmlDecode
andHtmlEncode
method. You could encode each array element, then join then with a ','. When you need the array again, split on ',' and decode each element. Fortunately, javascript also has both an encode and decode method that you could use. Works out great.Microsoft MVP, Visual C# My Articles