using hidden field to store value and use it in server side

Posted by Arun11 under ASP.NET on 7/28/2011 | Points: 10 | Views : 4077 | Status : [Member] | Replies : 3
Hi,

I have used radprompt for entering a filename.below is my javascript:
<script type="text/javascript>
function openPrompt() {
radprompt("please enter the file name", CallBackFn);
}
function CallBackFn(arg) {
alert(arg);
}</script>
The value that i enter is displayed in alert(arg).I don want to display in alert.Instead i want to store the value in a hidden field and use it in server side.how do i do that?please give me the code.

Thanks.




Responses

Posted by: Ashoknalam on: 8/5/2011 [Member] Starter | Points: 25

Up
0
Down
Put a Hidden filed in your ASPX page.

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


In your js function assign arg to hidden field.

<script type="text/javascript>

function openPrompt() {
radprompt("please enter the file name", CallBackFn);
}
function CallBackFn(arg) {
alert(arg);
document.getElementById("hdnVal").value = arg;
}</script>


Now you can access your hidden variable value in your code.


Ashok Nalam

Arun11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 8/5/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi Arun,

Ashok is right, n this code works until you have used ajax on your page

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Arun11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sundarsingh57 on: 8/8/2011 [Member] Starter | Points: 25

Up
0
Down
document.getElementById(hidden id).value = arg;


Jai Hind

Arun11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response