Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Passing values

Passing values

Scheduled Pinned Locked Moved ASP.NET
csharptestingbeta-testinghelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    perms
    wrote on last edited by
    #1

    I have dropdownlist control and text box control. I passsing this dropdownlist control and text box control values to another page, there i using request.querysting to get the parameter. but nothing is dipalying when i try to print. page1 Response.Redirect("testing.aspx?CategoryName = drlstCountry.SelectedItem.Text & GroupName = txtGroupName.Text",true); page2 string caName; string grName; caName = Request.QueryString["CategoryName"]; grName = Request.QueryString["GroupName"]; i am using c# , can anyone help me. thanks

    N 1 Reply Last reply
    0
    • P perms

      I have dropdownlist control and text box control. I passsing this dropdownlist control and text box control values to another page, there i using request.querysting to get the parameter. but nothing is dipalying when i try to print. page1 Response.Redirect("testing.aspx?CategoryName = drlstCountry.SelectedItem.Text & GroupName = txtGroupName.Text",true); page2 string caName; string grName; caName = Request.QueryString["CategoryName"]; grName = Request.QueryString["GroupName"]; i am using c# , can anyone help me. thanks

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Response.Redirect("testing.aspx?CategoryName =" + drlstCountry.SelectedItem.Text + "& GroupName = " + txtGroupName.Text,true); Is it a typo or did you forget the quotes?

      P 1 Reply Last reply
      0
      • N Not Active

        Response.Redirect("testing.aspx?CategoryName =" + drlstCountry.SelectedItem.Text + "& GroupName = " + txtGroupName.Text,true); Is it a typo or did you forget the quotes?

        P Offline
        P Offline
        perms
        wrote on last edited by
        #3

        still it is not working. i am sending the full code. after passing the value, i am stroing the image file in sql server 2000 database. -------------- public void UploadBtn_Click(object sender, System.EventArgs e) { if (Page.IsValid) { Stream imgStream = UploadFile.PostedFile.InputStream; int imgLen = UploadFile.PostedFile.ContentLength; string imgContentType = UploadFile.PostedFile.ContentType; byte[] imgBinaryData = new byte[imgLen]; int n = imgStream.Read(imgBinaryData,0,imgLen); int RowsAffected = SaveToDB( imgBinaryData); if ( RowsAffected>0 ) { Response.Write("
        The Image was saved"); } else { Response.Write("
        An error occurred uploading the image"); } } } private int SaveToDB(byte[] imgbin) { try { caName = Request.QueryString["CategoryName"]; grName = Request.QueryString["GroupName"]; SqlConnection connection = new SqlConnection "server=localhost;pwd=;userID=sa;data source=test"); Response.Write(caName); Response.Write(grName); SqlCommand command = new SqlCommand("Update BZZZ_Bzzzrings_Group set GroupImage = '" + imgbin + "' WHERE UserID = " + nUID + " AND CategoryName = '"+ caName +"' AND GroupName = '" + grName +"'",connection); connection.Open(); int numRowsAffected = command.ExecuteNonQuery(); connection.Close(); return numRowsAffected; } catch (SqlException ex) { throw new Exception(ex.ToString()); } finally { } }

        R 1 Reply Last reply
        0
        • P perms

          still it is not working. i am sending the full code. after passing the value, i am stroing the image file in sql server 2000 database. -------------- public void UploadBtn_Click(object sender, System.EventArgs e) { if (Page.IsValid) { Stream imgStream = UploadFile.PostedFile.InputStream; int imgLen = UploadFile.PostedFile.ContentLength; string imgContentType = UploadFile.PostedFile.ContentType; byte[] imgBinaryData = new byte[imgLen]; int n = imgStream.Read(imgBinaryData,0,imgLen); int RowsAffected = SaveToDB( imgBinaryData); if ( RowsAffected>0 ) { Response.Write("
          The Image was saved"); } else { Response.Write("
          An error occurred uploading the image"); } } } private int SaveToDB(byte[] imgbin) { try { caName = Request.QueryString["CategoryName"]; grName = Request.QueryString["GroupName"]; SqlConnection connection = new SqlConnection "server=localhost;pwd=;userID=sa;data source=test"); Response.Write(caName); Response.Write(grName); SqlCommand command = new SqlCommand("Update BZZZ_Bzzzrings_Group set GroupImage = '" + imgbin + "' WHERE UserID = " + nUID + " AND CategoryName = '"+ caName +"' AND GroupName = '" + grName +"'",connection); connection.Open(); int numRowsAffected = command.ExecuteNonQuery(); connection.Close(); return numRowsAffected; } catch (SqlException ex) { throw new Exception(ex.ToString()); } finally { } }

          R Offline
          R Offline
          Rocky Moore
          wrote on last edited by
          #4

          I am curious why you have to use two pages. In .NET, we often use on page and maybe transfer to a status page (I personally, normally include the status page, processing and data entry all on the same page and only enable the segments of the page I need at the moment). You would not want to use this code on a production server as you would be wide open for hacks. You never want to build a query string by just adding variables together. This allows a hacker to run SQL Injection attacks and you and lays your database and possibly web site wide open. Just search Microsoft for "SQL Injection" and you should find quite a bit of information. You will want to use parameters on the SQL Command. In your code it appears you are trying to capture and uploaded file. If you are redirecting to this page, that value will not be there. You also need to include your exact redirect code to make sure there is no errors in that. One other thought is that you might want to try Server.Transfer() instead of redirect. Redirect actually goes back to the browser and the browser then goes to the next page. If you use a Server.Transfer, it will simply output your new page and the client browser will not even know it is a different page. This should keep your parameters to the page to which you transfer. The transfer however, cannot take additional parameters, the second page will have the exact parameters your first page had. If you wish to provide additional parameters, you can pass them in the HttpContext.Current.Items["MyValue"] (use just like a session or application store. Rocky <>< www.HintsAndTips.com - Now with "Recommendation" postings www.JokesTricksAndStuff.com www.MyQuickPoll.com - Now with RSS Feed and Prizes www.GotTheAnswerToSpam.com - Again :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups