Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:55:20+00:00 2026-06-12T07:55:20+00:00

I want to get a codebehind value in my javascript function. My scenario is,

  • 0

I want to get a codebehind value in my javascript function. My scenario is, Lets say I have two Usercontrols A and B.
I am setting a global value from UserControl A. When I come to UserControl B’s page load, I am accessing that value and putting it into a hidden field.
I have a button on UserControl B which calls a javascript function on client click.
On that function I am trying to catch the hiddenfields current value. But I always get 0 from the hidden field value. What I am doing wrong? Can someone help me?

Below is the code:

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="DetailsForm.ascx.vb" Inherits="TD_Web_App.DetailsForm" %>
<script type="text/javascript">
function GetNextRecord() {
    debugger;
    var currentVal = $get("DetailsFormPanel_DetailsForm1_HFDetails").value; 
//clientID of my hidden field
}
</script>
<asp:UpdatePanel ID="DetailInfoUpdatePanel" runat="server" UpdateMode="Conditional" > 

  <ContentTemplate>
<table id="TDPropsGrid" runat="server" width="250px" ></table>
    <asp:Button ID="Cmd_Next" runat="server" Text="Next" Width="100px" SkinID="ButtonSkin" UseSubmitBehavior="false" OnClientClick="GetNextRecord()"/>
<asp:LinkButton ID="LinkButtonDetails" runat="server" style="display:none;">
LinkButton 
</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>

<asp:HiddenField ID="HFDetails" runat="server" />

On code behind:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    showData() 'some function
    HFDetails.Value = CurrentRecordCounter  ' global value coming from other usercontrol 
End Sub

'Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
'    HFDetails.Value = CurrentRecordCounter
'End Sub

I have tried putting

<asp:HiddenField ID="HFDetails" runat="server" /> 

inside the update panel, nothing changed.

But at GetNextRecord() the currentVal is always “0”. why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:55:21+00:00Added an answer on June 12, 2026 at 7:55 am

    Try:

    var currentVal = $('#<%=HFDetails.ClientID %>').val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i bascially want to get the value of a variable from the codebehind to
Basically I want get data I already have accessed from javascript and passing it
I want to pass some argument to javascript function from code behind. My Javascript
I have an asp.net application in which i want to get the value of
I want get as much as possible from Redis + Hiredis + libevent. I'm
What I want: get a xml from the AppData to use What I code
I want to get 100 and example from this string ?connect:100/username:example/ I searched in
I want to get the value of a hidden field in a grid view
I want to assign a value to an asp.net hiddenfield via javascript prior to
I have a gridview, and I'm trying to get the text value of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.