clerktech
clerktech

Reputation: 141

Passing QueryString ID from aspx page to winform textbox

I am currently developing an aspx page that calls a winform. The issue at hand is passing the textbox variable from the web page, through the ProcessStartInfo event, to the winform textbox to retrieve an image. The viewer is from a vendor but is only applicable in a winform environment but the other information is coming from a CF page, to an href and to a nonfunctional web image viewer. Is what I am doing possible?

Aspx page code:

namespace ImageView
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void page Load(object sender, EventArgs e)
        {
            TextBox1.Text = Request.QueryString["DKT_ID"].ToString();
            //TextBox2.Text = Request.QueryString["Name"].ToString();
            //TextBox3.Text = Request.QueryString["Age"].ToString();

ProcessStartInfo psi = new ProcessStartInfo(@"C:\ImageViewer\ImageView.exe");
            psi.WindowStyle = ProcessWindowStyle.Normal;

            Process p = new Process();
            p.EnableRaisingEvents = true;
            p.Exited += new EventHandler(MyExited);
            p.StartInfo = psi;
            p.Start();
        }

Winform code:

        //SQL section for returning images
        #region "Images Query"

        ImageQuery = "SELECT isn AS isn ";
        ImageQuery += "FROM bc_bcc_document (NOLOCK) ";
        ImageQuery += "WHERE barcode_id = ? ";

        DataTable Imagetable = new DataTable();
        Imagetable.Columns.Add("ISN", typeof(Int32));
        DataRow Imagerows;

        //fills table with Images information
        OdbcCommand comd = new OdbcCommand(ImageQuery);

        string conne = "Dsn=XXXX; uid=XXXXX; pwd=XXXXXX";

        using (OdbcConnection connected = new OdbcConnection(conne))
        {
            comd.Connection = connected;
            connected.Open();

            comd.Parameters.AddWithValue("barcode_id", txtBarcode.Text);

            OdbcDataReader readar = comd.ExecuteReader();

            while (readar.Read())
            {
                isn = Convert.ToInt32(readar["isn"].ToString().TrimEnd());
                Imagerows = Imagetable.NewRow();
                Imagerows["ISN"] = isn;
            }
            readar.Close();

Upvotes: 2

Views: 1526

Answers (2)

iuristona
iuristona

Reputation: 927

Did you try to use ClickOnce? I think could be interesting, once if your client doesnt have that application installed, clickOnce will do install before start the application.

And you can pass args also.

http://msdn.microsoft.com/en-us/library/ms172242(v=vs.110).aspx

Upvotes: 0

Mayur Dhingra
Mayur Dhingra

Reputation: 1577

Just pass the arguments from the web page like this

 var proc = new Process
 {
    EnableRaisingEvents = false,
    StartInfo = new ProcessStartInfo()
       {
           UseShellExecute = false,
           FileName = path,
           Arguments = Request.QueryString["DKT_ID"].ToString()
       }
  };
  proc.Start();

and read the command line arguments in your WinForms application like this -

string singleArgument = Environment.GetCommandLineArgs()[1];

P.S - assuming that you are passing a single argument, that's why Environment.GetCommandLineArgs()[1] is used because at [0]th position, you will get the path and [1]st position in the array would be useful to you.

Upvotes: 5

Related Questions