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 9226235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:46:51+00:00 2026-06-18T04:46:51+00:00

I am trying to pass values which I am taking from an external js

  • 0

I am trying to pass values which I am taking from an external js File into my .aspx page.

Here Is my .js file code:

function GETdateTime() {
    var d = new Date()
    var date = new String(d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear());
    var time = new String(d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds());
    document.getElementById("test").outerHTML = "<br>" + date + "<br>" + time;
}

In my .aspx page I am calling the above function and retrieving results like:

 <form id="form1" runat="server" method =" post">
    <span id = "test"> </span>

    <script type =" text/javascript" src="JavaScript1.js"  >
    </script>     

     <script type ="text/javascript">
            GETdateTime();
     </script>
</form>

What I am trying to achieve is that I am planning to have one HiddenField which would store the date, time and other things and then grab the values in that HiddenField and pass them to my vb.net code behind to store them in a string. The problem is that I have seen to many approaches and I am kind of confused with which one to go with like here,here and here. I am also considering efficiency, consistency, flexibility and overall performance. Any thoughts or suggestions would be appreciated.

  • 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-18T04:46:53+00:00Added an answer on June 18, 2026 at 4:46 am

    If you have a form like this:

    <form id="form1" runat="server" method =" post">
        <asp:HiddenField runat="server" id="test" />
        <script type =" text/javascript" src="JavaScript1.js"  >
        </script>     
    
         <script type ="text/javascript">
                GETdateTime("<%=test.ClientID %>");
         </script>
    </form>
    

    Than you need a javascript:

    function GETdateTime(hiddenFieldID) {
        var d = new Date()
        var date = new String(d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear());
        var time = new String(d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds());
        document.getElementById(hiddenFieldID).value = "<br>" + date + "<br>" + time;
    }
    

    Than, in code behind after form submitted, to get a value set with JS you can simply do:

    hiddenFieldVal = test.Value 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to pass two values to php file via ajax my code
I have problem when I am trying to pass values back from my page
I am trying to pass items from a mysql database into an xml file
I am trying to pass values from a ruby hash to a bash script..
I've got this JS highchart that I'm trying to pass some values into that
I'm trying to pass a query string from one page to another page where
I'm trying to parse a page for which I've to first log into that
I am trying to pass values gathered from PDO in the Datamanager object to
I'm trying to pass an array from a jQuery function to my controller. The
I am trying to pass values of textbox with same name from JSP to

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.