I have a Javascript function that pulls down variables, like so:
function OnClientCloseSecure(oWnd, args) {
var arg = args.get_argument();
if (arg) {
var ResultCode = arg.ResultCode;
var PONumber = arg.PONumber;
}
}
I need to assign ResultCode and PONumber to a variable in C# or if that isn’t possible a label in c#.
Are any of these options possible? If so, how would I go about doing that? I’ve tried several things with no luck. Thanks!
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
One way would be to create hidden value and set the runat attribute to server. you can get the
value.
<script type="text/javascript">
function abc()
{
var str="value";
document.getElementById("Hidden1").value=str;
}
</script>
<input id="Hidden1" type="hidden" runat="server" />
Code Behind:
string value = Hidden1.Value;
Method 2
JavaScript
<script type="text/javascript">
function OnClientCloseSecure(oWnd, args) {
var arg = args.get_argument();
if (arg) {
var ResultCode = arg.ResultCode;
var PONumber = arg.PONumber;
document.getElementById('<%=lbl.ClientID %>').innerHTML = ResultCode;
}
}
</script>
Mark Up
<asp:Label ID="lbl" runat="server" ></asp:Label>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0