Note that there are some explanatory texts on larger screens.

plurals
  1. POPass values to an asp hidden field from an external .js file
    primarykey
    data
    text
    <p>I am trying to pass values which I am taking from an external js File into my .aspx page. </p> <p>Here Is my .js file code: </p> <pre><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 = "&lt;br&gt;" + date + "&lt;br&gt;" + time; } </code></pre> <p>In my .aspx page I am calling the above function and retrieving results like: </p> <pre><code> &lt;form id="form1" runat="server" method =" post"&gt; &lt;span id = "test"&gt; &lt;/span&gt; &lt;script type =" text/javascript" src="JavaScript1.js" &gt; &lt;/script&gt; &lt;script type ="text/javascript"&gt; GETdateTime(); &lt;/script&gt; &lt;/form&gt; </code></pre> <p>What I am trying to achieve is that I am planning to have one <code>HiddenField</code> which would store the <code>date, time and other things</code> and then grab the values in that <code>HiddenField</code> 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 <a href="http://www.foliotek.com/devblog/extending-jquery-to-select-asp-controls/" rel="nofollow noreferrer">here</a>,<a href="http://forums.asp.net/t/1238046.aspx/1" rel="nofollow noreferrer">here</a> <a href="https://stackoverflow.com/questions/1861103/how-can-i-access-server-controls-from-my-external-javascript-file">and here</a>. I am also considering efficiency, consistency, flexibility and overall performance. Any thoughts or suggestions would be appreciated. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload