Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 30, 2010 06:59 PM by fanette48
Feb 07, 2007 07:04 AM|LINK
if (Request.QueryString["param1"] != null)
Response.Write("From Page1 param1 value=" + Request.QueryString["param1"]);
This is how you pass parameters from one page to another in C#
hi, how do I know which should I put it in response.redirect( )?
I have 2 page now ( a is writted by VB .. I can't modify it.. , b is writted by C#)
page a is shows many title... and once user click one of them it will direct to page b. page b will shows content which user click from page a..
so that's why I'm wondering .. is it ok? get parameter in url when we are in page b...
By default VS doesnt allow multiple language compilation. If you want to have mutiple language compilation you need to add the following section in web.config file and your code should go into the respective folders under the App_Code
<add directoryName="VBCode" />
<add directoryName="CSCode" />
Feb 08, 2007 02:07 AM|LINK
thank you ~
Fredrik N 、fafar 、e_screw 、sreejith77
beause all of your help and patient.. I've resolve my question
I just simply add code like below on the second page
and it does work perfect right now..
really appreciate for your help . thanks again ~!![Angel]
Feb 13, 2007 06:23 AM|LINK
sorry for asking same question again..
I don't know what's going wrong . I use the same way to get prameter from URL and put it on SQL Query string for select data...
but it doesn't work at all... label1.text and label2.text seems empty...
below is my code... can you point me where I did wrong please? thank you
string a= Request.QueryString["cid"].ToString(); // my url is like "http://localhost/news_c.aspx?cid=14&FK=1"
string strConn = "data Source=x.x.x.x;user=sa;password=1234 ;initial catalog=guestbook";
string strSQL = "select Subject,nContent from message where cid=" + a;
SqlConnection conn = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand(strSQL, conn);
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader();
this.Label1.Text = (dr["Subject"].ToString());
this.Label2.Text = (dr["nContent"].ToString());
Feb 13, 2007 06:34 AM|LINK
Make sure you are getting the correct value into a. Since you are not getting any exception, seems you are getting the correct value else an exception would be raised for the incorrect sql statement. Also check how many rows are returned by your sql statement.
If you have multiple rows returned, the dr.Read() in while will loop through all the rows and sets the label's with the last values in the records returned
Feb 13, 2007 06:38 AM|LINK
hm.... I don't know what's going wrong actually...[:S]
I move these code from event Page_load to event button_click
it does work ...
but in previous practice I put code in event page_load it doesn't work..and now it doesn't...
Feb 13, 2007 07:10 AM|LINK
thank you e_screw
I put a bottom to form and raise a button_click event.
and then move code from event-Page_load to event-button_click
label1 and label2 will shows correct information which I get from SQL Query after I click bottom..
is anything wrong I put the code in event- page_load? how come is doesn't work ?
thank you very much
Feb 13, 2007 07:37 AM|LINK
The same code should work in the Page_Load also if you are getting the correct value in the cid. Check this line by keeping a break point.
string a= Request.QueryString["cid"].ToString();
Feb 13, 2007 07:51 AM|LINK
thank you e_screw again
can you please teach me how to run a break point ?
I put a break point on String a= Request.QueryString["cid"].ToString(); and then run the program
nothing happen... is this what I have to do? or should I get any information from set a break point? ( I'm sorry but I really not similiar with this step_
thank you very much
Feb 13, 2007 08:25 AM|LINK
On the line of code (text cursor on this line) String a= Request.QueryString["cid"].ToString(); press F9 which will keep a break point on that line (the entire line turns brown in color).
Now press F5, and when the break point line of code is reached, the execution breaks, and that line turns yellow. Keep cursor on the variable or controls properties on the yellow line and you will see a white tool tip showing its values. You can also use Watch
window, to write the expression and look at its value.
// Note your break point will hit, only when you access that page in which you have kept the break point
Feb 13, 2007 08:53 AM|LINK
thank you !!! very clearly... and I did as the folllow you taught..
but I find the problem... break point never hit... so is it mean program never run the event -page_load??
I now have 2 webpage new_s and news_c
when user click item on new_s page will trun to new_c and shows item's detail which user just clicked...
news_c need to get parameter from URL so that can Query which item should be show..
but now seems page_load didn't invoke when news_s trun to news_c? right?[:S]
thank you again