How to pass parameters from html page to constructor of a class in C# [Resolved]

Posted by Kasani007 under C# on 10/19/2016 | Points: 10 | Views : 132 | Status : [Member] | Replies : 1
How to pass parameters from html page to constructor of a class in C#

I had given as below:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var ItemId=1000 ;
function OpenReport() {
var invoiceNum = document.getElementById("TextBox1").value;
window.open('http://localhost:58838/Html5ReportViewer1.html?ItemId=' + ItemId, '_blank');
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;
<input type="button" value="Print Now" onclick="OpenReport()"/>
</div>
</form>
</body>
</html>



But the HTML page is Not Taking Values As Parameter Like ASPX Page,
How can i pass parameters via html page




Responses

Posted by: Rajnilari2015 on: 10/19/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
@Kasani007 Sir, you need to use
 document.location.href 
in the called page. An example follows

1.html
--------
<html>
<head>

<script type='text/javascript'>
var ItemId=1000 ;
function OpenReport() {
window.open('2.html?ItemId=' + ItemId, '_blank');
}
</script>
</head>
<body>
<input type="button" value="Print Now" onclick="OpenReport()"/>
</body>
</html>


2.html
----------
<html>
<head>
<script type='text/javascript'>
window.onload = function () {
var url = document.location.href;
document.getElementById('txtItemID').value = url.split('?')[1].split('=')[1];
}
</script>
</head>
<body>
ItemId : <input type ="text" id="txtItemID" readonly>
</body>
</html>


Hope that helps.

--
Thanks & Regards,
RNA Team

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

Login to post response