Click here to Skip to main content
13,149,427 members (53,375 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have function in javascript and a hiddenfield. I'm initializing hiddenfiled with value="False" and I set the value for hiddenfiled in Page event for Datagrid as "True". Now I'm calling my javascript function from Page event form codebehind where I need to check the value of hiddenfield but the value which is set as "True" is not displayed in alert box for the first time i.e. for the first time it shows value as "False" and from second time it shows correct value as "True".

Javascript code is:

function show()
var hdn=document.GetElementById('hdnShow').value;

<asp:HiddenField Id="hdnShow" Value="False" runat="Server" />

VB.NET Code for Datagrid Event:

Protected Sub dgttumfileview_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgttumfileview.PageIndexChanged
            If (Not ClientScript.IsStartupScriptRegistered("alert")) Then
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "show();", True)
            End If
                    Catch ex As Exception
            Trace.Warn("dgUnPaidScroll_PageIndexChanged", ex.Message)
        End Try
    End Sub

How can I get the correct set value for hiddenfield from first time when I call javascript function ??
Posted 8-Nov-12 17:34pm
Updated 8-Nov-12 17:47pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please try this..!

function show()
var hdn=document.getElementById('<%= hdnShow.ClientID %>').value;
swatiiiiiiiiii 9-Nov-12 4:17am
It gives error 'Object doen't support this property'
Ravi Tuvar 9-Nov-12 6:38am
May you try and see the updated solution?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100