Passing HTML Page Parameters to ASP.NET

0

I have an asp.net page which I need to get parameters from an HTML template . I'm trying the way below but I can not get the values. Here is my code:

HTML - Template

<form method="post" action="http://localhost:61712/Default.aspx">

<TABLE>
<TBODY>
  <TR>
      <tdTEXT-ALIGN: center">
          <p><font size="3"><b>Solicitacao Nr. %NUMSC% </b></font> 
        <input type="hidden" name="NumeroSC" value="%NUMSC%" /> 

      </td>
   </tr>
</tbody>
</table>
</form>

My ASP.NET page Default.aspx

<%@ import Namespace="System.Data.SqlClient" %> 

<script runat="server">
        protected void Page_Load(Object Src, EventArgs E)
        {
            string host = "******";
            string usuario = "******";
            string senha = "******";
            string banco = "******"; 

            var Compra = Request.Form["NumeroSC"];

            string strSQL = "SELECT codigo as Numero, arquivo from MeuDatabase where codigo like '%Compra%'"; // é dessa forma que pego o parametro na string? Já tentei também + Compra +             

            SqlConnection conexao = new SqlConnection("Data Source=" + host + ";DATABASE=" + banco + ";UID=" + usuario + "; PWD=" + senha + ";");

            conexao.Open();  

      ...      

When running my ASP.NET page, the page returns no value for the query. I have already tried in HTML in value pass an existing fixed value but also in my query does not return value.

What am I doing wrong? How can I get this parameter %NUMSC% correctly?

EDIT

This form is not a submit, it's a template. Each new request is assembled and filed one html, one for each request. My desire is that with every html I open I call the asp.net page with the information for that specific file number. It works like this: an approving user receives an email with the link pointing to the html (invoice). I wanted it when the user opened the link he would see the data he already sees more a "frame" embedded in that html that is a href pointing to the attachment (document) referring to that invoice. The point is that I can not edit the code of the program that generates the invoice to already bring this information. So I saw the need to create an ASP.NET page.

    
asked by anonymous 01.07.2015 / 16:32

1 answer

2

If you understand correctly, what you do is: after completing the request, an HTML is generated from this template, only with the request number filled in.

What you want to do is: after sending this HTML by email and when accessed, fetch more data from that number that is in the HTML and fill it out.

Am I right? If I am, I imagine three options:

  • Create the HTML already with all the data filled (I see no reason not to do so, unless the data is not in readiness);
  • E-mail a link pointing to an ASPX page with the request number as a parameter (example: geranotafiscal.aspx? request = 12345) and when you access it generates this HTML with all the information, sending it to the user;
  • In the way you want, just having the request number in HTML and when the user opens, fill in the other data, I imagine it is possible only with javascript, in the load event, make ajax a request for your page, parameter and returning the desired data.
  • The last solution will be a lot of work and will have the same result as the first one. If you can not do the first one for the reason I quoted or something similar, do the second one.

    The solutions presented above, consider the need for the file to be HTML, making it available for download. If it's just for presentation, create an ASPX in the format of the invoice, with the labels and everything else, do as in solution 2, pass a link of type notafiscal.aspx? Request = 12345 and in PageLoad, get the request number, search the data and fill in the labels.

        
    01.07.2015 / 18:45