?
Solved

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

Posted on 2009-04-22
5
Medium Priority
?
386 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:Samm1502
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:Faheem Shaikh
ID: 24203434
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
 

Author Comment

by:Samm1502
ID: 24203570
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
 
LVL 8

Accepted Solution

by:
Faheem Shaikh earned 1500 total points
ID: 24203653
Well, then you can use the session variables.
0
 

Author Comment

by:Samm1502
ID: 24203906
Didn't think of that!  
Cheers
Sam
0
 

Author Closing Comment

by:Samm1502
ID: 31573206
S
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question