Passing values
-
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
-
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
Response.Redirect("testing.aspx?CategoryName =" + drlstCountry.SelectedItem.Text + "& GroupName = " + txtGroupName.Text,true); Is it a typo or did you forget the quotes?
-
Response.Redirect("testing.aspx?CategoryName =" + drlstCountry.SelectedItem.Text + "& GroupName = " + txtGroupName.Text,true); Is it a typo or did you forget the quotes?
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 { } } -
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 { } }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 :)