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

Posted on 2009-04-22
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.
<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

Question by:Samm1502
    LVL 8

    Expert Comment

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

    Author Comment

    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.

    LVL 8

    Accepted Solution

    Well, then you can use the session variables.

    Author Comment

    Didn't think of that!  

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
    In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now