Link to home
Start Free TrialLog in
Avatar of johnkainn
johnkainn

asked on

webusercontrol - Unable to set value of the property 'value': object is null or undefined

Hello,
If I have this in web user control (.ascx) I get an error but when it is in aspx page then there is no error. Do you know why that is?
 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function buildArgument(sender, args) {
                var t = "K";
                document.getElementById("argument").value = t;
            }
        </script>
    </telerik:RadScriptBlock>
          <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:HiddenField ID="argument" runat="server" />
    <asp:Button ID="SelectButton" runat="server" Text="Select" Width="100px" OnClick="SelectButton_Click"
                OnClientClick="buildArgument(this, event);" />

Open in new window



Microsoft JScript runtime error: Unable to set value of the property 'value': object is null or undefined
In the debugger this gets highlighted:
document.getElementById("argument").value = t;

Open in new window

Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Where is the element with id="argument" defined, I don't see it anywhere?

Cd&
Avatar of johnkainn
johnkainn

ASKER

It is hiddenfield, 3rd line from the bottom. (line 10)
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada 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
I found the answer. I set ClientIdMode="Static" in the HidenField. Then it works.