Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all,
In my web application to avoid tampering i want to send textbox value in java script variable to .cs page and use it. but i dont want to use hidden field.
Example:-
JavaScript
var data = document.getElementById('<%=RandomList.ClientID%>').value;

I want to use this "data" value from code behind.

Please help if possible... thanks in advance...
Posted
v3
Comments
Why are you going for a difficult and lengthy approach ?
To avoid tampering, better to validate all data before inserting/updating to database.

But assigning the server variable's value to an JavaScript variable and then again accessing that in code behind is not the usual way.
Avinash_Pathak 12-Dec-12 2:04am    
ok sir...but how to validate them...?
Can you tell me what exactly you want to validate ?
Or do you want to validate all fields in your form ?
Please tell me what are the fields in your form and post some relevant codes.

And one thing, please don't call me sir, I am very young ;) :P
Avinash_Pathak 12-Dec-12 3:01am    
<form name="form" action="Default.aspx" method="post">
<td> Amount: </td>
<td><input type="text" name="mmount" /></td>
</tr>
<tr>
<td class="style34"> Name</td>
<td class="style1"><input type="text" id="name" name="txtname" size="45" /> </td>
</tr>
<tr>
<td> EmailID</td>
<td><input type="text" name="txtEmailID" size="35" /> </td>
</tr>
<tr>
<td><br/>
<input type="submit" value="SUBMIT" />
<br /> </td>
</tr>

this is my code...now I dont want any of textfield value can tamper on submit click..

1 solution

JavaScript
var data = <%=my_public_variable_from_code_behind%>; // for a number

var data = "<%=my_public_variable_from_code_behind%>"; // for a string
 
Share this answer
 
v2
Comments
Avinash_Pathak 12-Dec-12 12:23pm    
i want to use this data variable value in code behind,,,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900