I need help getting a web page element id out of a string variable to be used within my c# code behind page.
I am trying to display a string in a literal control telling the user what was wrong with the input that they provided in the associated text box. my error string looks like this:
Expand|Select|Wrap|Line Numbers
- errorMsg = "litLastName-Please enter a valid last name"
here is my code thus far in C#:
Expand|Select|Wrap|Line Numbers
- {
- string errorMsg = hdnErrorMsg.Value;
- litResults.Text = errorMsg;
- //breaks up the mass error string into individual error strings
- string[] errorMsgSplit = errorMsg.Split('/');
- string strLitErrorElement = "";
- string strLitErrorMsg = "";
- for (int i = 1; i < errorMsgSplit.Length; i++)
- {
- strLitErrorMsg = strLitErrorMsg + errorMsgSplit[i];
- litResults.Text = strLitErrorMsg;
- //splits the individual error strings into the asp lit and lit text
- string[] indErrorMsg = errorMsgSplit[i].Split('-');
- strLitErrorElement = indErrorMsg[0];
- strLitErrorMsg = indErrorMsg[1];
- (here is the part where I'm stuck)
- }
- }
Expand|Select|Wrap|Line Numbers
- litLastName.text = "Please enter a valid Last Name"