Passing HTML page parameters to ASP.NET

Asked

Viewed 1,496 times

0

I have an Asp.net page that I need to get parameters from template HTML. I am trying the way below but I am not getting the values. Follow 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 page ASP.NET 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 does not return any value for the query. I have tried it in HTML at 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 right %NUMSC%?

EDIT

This form is not a Ubmit, it is a template. Every new request is mounted and filed an html, one for each request. My wish is that every html I open I call the Asp.net page with the information of that specific file number. Here’s how it works: an approving user receives an email with the link pointing to html (invoice). I wanted that when the user opened the link he would see the data that he already sees currently another "framezinho" embedded in this html that is a href pointing to the attachment(document) referring to that invoice. The point is, I can’t edit the code of the program that generates the invoice to already bring that information. So I saw the need to create an Asp.net page.

  • Hello. You check in the browser if the value input is set correctly. Also check if the form is being submitted to the page, as I have not seen any input to do Submit.

  • I already passed a value on the specific input but it still didn’t. This form is not a Ubmit, it’s a template. Each new request is mounted and archived with an html, one for each request. My wish is that every html I open I call the page Asp.net with information from that specific file number.

  • I don’t understand. Define template. What is the execution flow? When this form is submitted?

  • @Caiquec. there is a program that when the user completes the request is generated a tax note that is an HTML. I can’t touch the source code of this application. This code that I ran above is the standard template for the FY notes. What will change in each generated HTML is the Request Number and the other fields. So I have a blank HTML (template) and several others filled with your information (Multiple Tax Notes) When a new tax note is generated, I receive by email a link pointing to one of these respective html ready with the data.

  • @Caiquec. What I need is to click and open the html I rescue in it data from this page Asp.net. What I’m trying to do first is to talk html to the Asp.net page to bring the other information I need to add to the invoice.

1 answer

2

If I understand correctly, what you do is: after completion of the request, an HTML is generated from this template, only with the completed request number.

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

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

  1. Create HTML with all data already filled (I see no reason not to do so, unless the data is not ready);
  2. E-mail a link pointing to an ASPX page with the request number as parameter (example: geranotafiscal.aspx?solicitacao=12345) and when accessing you generate this HTML with all the information, sending it to the user;
  3. The way you want it, having only the number of the request in an HTML and when the user opens, fill in the other data, I imagine it is possible only with javascript, in the load event to make by ajax a request to your page, passing the parameter and returning the desired data.

The last solution will take a lot of work and will have the same result as the first. If you can’t do the first one for the reason I mentioned or something, do the second.

The solutions presented above consider the need for the file to be HTML, available for download. If it’s just for presentation, create an ASPX in the format of the invoice, with the Abels and everything, do as in Solution 2, pass a link of type notafiscal.aspx? request=12345 and on Pageload, take the request number, search the data and fill in the Abels.

  • Thank you @Caiquec. That’s pretty much what you got, apart from the fact that I want to carry other fields. Actually I want a new field to appear which will be a link to an attachment file. The point is that I can not as I said change anything in the html generation. I have to take this one way or another, in the case the page Asp.net. Solution 2 I believe serves me yes. How do I pass this link and receive on Pageload? Can you give me an example?

  • Sorry, I understood that you sent the email with the link. Isn’t that it? How is it?

  • Yes, the approving user receives an email with the link pointing to html (invoice). I wanted that when the user opened the link he would see the data that he already sees currently another "framezinho" embedded in this html that is a href pointing to the attachment(document) referring to that invoice. The point is that I can’t edit the default html or the program that generates the invoice. So I saw the need to create an Asp.net page. It would be like calling an application when opening html.

  • The user receives a link to the invoice (HTML) and what you want to do is that when he clicks on this link, he sees the invoice with more information (link to download the attachment)?

  • That’s right! Need not even download, just view. I will upload all the files to the file server along with the application.

  • But you send the e-mail? If yes, the solution 2 is acceptable, but you would need to change the link sent by email, pointing to a page of your own, not to the generated HTML and you would also need to have the request number.

  • No, the same program that generates the invoice sends the email. I can only manipulate the link comes in the email, in case the HTML

  • I cannot through the generated html open my page?

  • This pattern template I talked about would be the template through which all invoices are generated and saved. My idea was in this pattern point to my page so that all other generated invoices are created and saved pointing to my application so that always when opening them it is possible to see the attached files coming from the new Asp.net page

  • Being HTML, its only output for processing is Javascript.

  • And do you know what a Javascript would be like for this? I would still need the Asp.net page in the same way ne?

  • No. You would have to do a GET via Javascript to a url, passing the request number, like "dadossolicitacao.aspx? request=12345" that would be your page Asp.net. Ai in Pageload, that is, when you hit the url, takes the request number (Querystring), pulls the items and returns as Json. When you return the data you fill the HTML, also with Javascript. I have no knowledge to pass the code to you, but I know it is simple. Search on how to do a GET with Ajax and Jquery. links: https://api.jquery.com/jquery.get/, http://www.w3schools.com/jquery/jquery_ajax_get_post.asp.

  • Just remember that if the answer helped you, mark it as correct.

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.