Winnovative With Parameters in URL

220 Views Asked by At

i have a big problem and i need your help. i'm trying send to url parameters to generate the pdf file with the library winnovative. when trying the first time I have no problems and generates pdf but if I want to get the pdf again this gives me error because the parameters in url they are sent and fail to request and falls when so finally assign to generate the pdf file. I have attached the code for review:

 public override void Pagina_PrimeraCarga(object sender, EventArgs e)
    {

        string datosRequest = Request.QueryString["DATOS"];
        char delimitadores = ';';
        string[] datos = datosRequest.Split(delimitadores);

        imgBanco.Attributes.Add("ImageUrl", "~/App_Themes/Imagenes/Logo.gif");
        System.DateTime fecha = new System.DateTime(2014, 12, 17);
        lblDia.Text = Convert.ToString(fecha.Day);
        lblMes.Text = Convert.ToString(fecha.Month);
        lblAno.Text = Convert.ToString(fecha.Year);

        string rutEmpresa = datos[3];
        int rut = Convert.ToInt32(rutEmpresa);
        string rutRes = rut.ToString("N0", CultureInfo.InvariantCulture).Replace(",", ".");
        rutRes = rutRes + "-" + datos[4];

        lblOficina.Text = "OFICINA: " + datos[0];
        lblNombreTitular.Text = "NOMBRE TITULAR: " + datos[1];
        lblRut.Text = "R.U.T.: " + rutRes;
        lblDireccion.Text = "DIRECCION: " + datos[2];
        lblFono.Text = "FONO: " + datos[5];
    }

P.D: my apologies for my bad English but my native language is Spanish P.D.2: Thanks to everyone who could help me in this case

2

There are 2 best solutions below

0
On BEST ANSWER

I have solved the problem. I was thinking a bit and detects when passed a second time to obtain the pdf that was creating the cookie to be passed to the other form was created and therefore did not pass the data. for this reason I had to add 2 lines but my code for closing the pdf this server delete the cookie and when consulted again remove the client:

Response.Cookies.Clear ();
myCookie.Expires = DateTime.Now.AddDays (1D);
16
On

I think that your problem is that after postBack your query string will be empty. Try this

add hiddenfield

<asp:HiddenField runat="server" ID="hidden1" />

then in your pageLoad

 if (!IsPostBack)
 {
   string datosRequest = Request.QueryString["DATOS"];
    if(datosRequest  != null)
    {
      //do something
      hidden1.Value = datosRequest ;
    }
 }
 else
 {
   datosRequest = hidden1.Value;
 }