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

  • Home
  • SEARCH
  • 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 5946005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:45:41+00:00 2026-05-22T16:45:41+00:00

I have following JavaScript function, Which call Jquery JSON function and get the DateTime

  • 0

I have following JavaScript function, Which call Jquery JSON function and get the DateTime with respect to timezone. This works fine.

  <script type="text/javascript">
    function JSFunctionName() {
        $(document).ready(function () {
            var timezone = "US/Central";
            $.getJSON("http://json-time.appspot.com/time.json?tz=" + timezone + "&callback=?",
function (data) {
    if (data.hour < 12) {
        //alert(data.hour + ':' + data.minute); // want to return this value data.hour + data.minute
        //document.getElementById('<%=HiddenField1.ClientID %>').value = data.hour + ':' + data.minute;// this does not work
    }
})
        });
    }
</script>

Now I am calling this Javascription function in Code behind on onclick of button

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

Code behind

protected void Button1_Click(object sender, EventArgs e)
{
    Page.ClientScript.RegisterStartupScript(this.GetType(),
        "alert", "JSFunctionName();", true);
    // here I need the DateTime value that is get from JSON
    //Response.Write(HiddenField1.Value); 
}

How can I return the value from Javascript to code behind immediate after call of Page.ClientScript.RegisterStartupScript

Please note I have try to set the value in HiddenField, but its not working. you can see in the comment.

Any idea or alternative solution will be appreciated.

Thanks

  • 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-05-22T16:45:41+00:00Added an answer on May 22, 2026 at 4:45 pm

    You can’t do this without posting back to the server. The reason for this is that javascript executes on the client, and it will only execute after the page has left the server.

    I assume this is a contrived example, but in this specific case, if you want to have the same information available on the client and server, you need to compute it on the server, and pass that out to the client.

    If this isn’t possible, you’ll need to create a webservice, but that will have to handle the response asynchronously.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JavaScript code: Link In which the function makewindows does not
I have the following javascript code, which loads without error, however the update function
I have the following javascript function: <script type=text/javascript> function quickCardRegister_OnCompleteSave() { publishContent('This is a
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I have the following jquery function > <script type=text/javascript> > > $(document).ready(function() { >
I have the following situation in JavaScript: <a onclick=handleClick(this, {onSuccess : 'function() { alert(\'test\')
I have the following JavaScript (I'm using jQuery): function language(language) { var text =
i have one jquery function which i need to work in following way 1.
I have the following javascript code: $.get(categories/json_get_cities/ + stateId, function(result) { //code here },
I have a jquery question about selecting Id. Basically, I call a javascript function

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.