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.
<html xmlns="" >
<head runat="server">
<script type="text/javascript">
        var searchValuesLabel;
        var sSearchValues = window.dialogArguments;
        searchValuesLabel = document.getElementById("<%= SearchValuesLabel.ClientID %>");
        searchValuesLabel.value = sSearchValues;
    <title>Search Fields</title>
    <div id="SearchFields">
        <asp:Label Text="" runat="server" ID="SearchValuesLabel" Visible="true"></asp:Label>    

Open in new window

Who is Participating?
Faheem ShaikhConnect With a Mentor Commented:
Well, then you can use the session variables.
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.
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.

Samm1502Author Commented:
Didn't think of that!  
Samm1502Author Commented:
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.