Friday, April 27, 2012

pass variable from codebehind to aspx (client side) in || pass value from server side to client side in

In previous post i have given how to pass the variable value from client side  to server side (code behind).Now i will show how to pass the variable from code behind to aspx .Here i would not use any javascript or etc.Because there is so many ways to get the values to javascript variables from code behind.This process easy to understand for developers and who has not much knowledge in javascript.
<form  method="post" action="Calculation.aspx">
    <input id="h1" type="hidden" name="cart"  value="<%=strEncoded %>"/>
    <input id="h2" type="hidden" name="signature" value="<%=sign %>"/>
    <input type="button" name="submit"/>
When ever we assign the values to html control ,Those should be declare as "public" variable.Here the strEncoded,sign are passed to client side using "<%= >"
 public String strEncoded;
 public string sign;
 strEncoded = "Encode string";
 sign= "teststring";

No comments: