Link to home
Start Free TrialLog in
Avatar of Samm1502
Samm1502

asked on

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

Avatar of Faheem Shaikh
Faheem Shaikh
Flag of India image

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.
Avatar of Samm1502
Samm1502

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Faheem Shaikh
Faheem Shaikh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Didn't think of that!  
Cheers
Sam
S