How to set a Label control with value passed in window.dialogArguments property

Hi I have an ASP.NET page that opens a modal dialoge box and tries to set the value of a label to the value passed in the dialogArguments property but I kep getting an unhandles exception with the following error message:

"The Controls collection cannot be modified because the control contains code blocks(i.e.<% %>)"

Now my code is below and does contain code blocks in oredr to reference the label I am interested in.  So how do I set the label without the code blocks???

Any help much appreciated.
Cheers
Sam
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script type="text/javascript">
     <!--
        var searchValuesLabel;
        var sSearchValues = window.dialogArguments;
 
        searchValuesLabel = document.getElementById("<%= SearchValuesLabel.ClientID %>");
        searchValuesLabel.value = sSearchValues;
    -->  
</script>
    <title>Search Fields</title>
</head>
<body>
    <div id="SearchFields">
        <asp:Label Text="" runat="server" ID="SearchValuesLabel" Visible="true"></asp:Label>    
    </div>
</body>
</html>

Open in new window

Samm1502Asked:
Who is Participating?
 
Faheem ShaikhConnect With a Mentor Commented:
Well, then you can use the session variables.
0
 
Faheem ShaikhCommented:
When you open the new dialog box, why not pass the name as a querystring to the dialog box. Then do Request.Querystring to get the value and set it as the label name.
0
 
Samm1502Author Commented:
I don't want to do that because some of the arguments I am going to pass will be private so
would rather simulate posting the data.

Sam
0
 
Samm1502Author Commented:
Didn't think of that!  
Cheers
Sam
0
 
Samm1502Author Commented:
S
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.