| |

VerySource

 Forgot password?
 Register
Search
View: 852|Reply: 2

Ask experts to teach very simple questions  I'm confused

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-11-26 16:00:01
| Show all posts |Read mode
Teachers, please help me to see what is wrong with my program
I will select or fill in the content on the first page to the second page, but there is a lot of content to be passed
I wrote this
Response.Redirect("http://localhost/sycar/cn/find2.aspx?type='"+ddl1.SelectedItem.Text.ToString()+"'&name='"+tbname.Text.ToString()+" '&price='"+ddl3.SelectedItem.Text.ToString()+"'&year='"+ ddlyear.SelectedItem.Text.ToString()+"'&month='"+ddlmonth.SelectedItem.Text.ToString()+ "'&day='"+ddlday.SelectedItem.Text.ToString()+"'&area='"+ddl5.SelectedItem.Text.ToString()+"'&dang='"+ddl6.SelectedItem.Text.ToString() +"'&oil='"+ddl7.SelectedItem.Text.ToString()+"'");
The second page is written like this
string type1=Page.Request.QueryString["type"].ToString().Trim();
string name1=Page.Request.QueryString["name"].ToString().Trim();
string price1=Page.Request.QueryString["price"].ToString().Trim();
string year1=Page.Request.QueryString["year"].ToString().Trim();
string month1=Page.Request.QueryString["month"].ToString().Trim();
string day1=Page.Request.QueryString["day"].ToString().Trim();
To
string area1=Page.Request.QueryString["area"].ToString().Trim();
string dang1=Page.Request.QueryString["dang"].ToString().Trim();
string oil1=Page.Request.QueryString["oil"].ToString().Trim();
To
strSql="select * from zcar where 1=1";
if(type1!="")
{
strSql +=" and type='"+type1+"'";
To

}
if(name1!="")
{
strSql +=" and name='"+name1+"'";
To
}
if(price1!="")
{
strSql +=" and price='"+price1+"'";
}
if(year1!="")
{
strSql +=" and yizumoyear<'"+year1+"'";
}
if(month1!="")
{
strSql +=" and yizumomonth<'"+month1+"'";
}
if(day1!="")
{
strSql +=" and yizumoday<'"+day1+"'";
}
if(area1!="")
{
strSql +=" and suozaidi='"+area1+"'";
}
if(dang1!="")
{
strSql +=" and chedang='"+dang1+"'";
}
if(oil1!="")
{
strSql +=" and ranyou='"+oil1+"'";
}
But when running, when I select a content on the first page, I always make a mistake on the second page and say that there is a syntax error near the content I selected.
Reply

Use magic Report

0

Threads

58

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-11-26 21:30:01
| Show all posts
Response.Redirect("http://localhost/sycar/cn/find2.aspx?type='"+ddl1.SelectedItem.Text.ToString()+"'&name='"+tbname.Text.ToString()+" '&price='"+ddl3.SelectedItem.Text.ToString()+"'&year='"+ ddlyear.SelectedItem.Text.ToString()+"'&month='"+ddlmonth.SelectedItem.Text.ToString()+ "'&day='"+ddlday.SelectedItem.Text.ToString()+"'&area='"+ddl5.SelectedItem.Text.ToString()+"'&dang='"+ddl6.SelectedItem.Text.ToString() +"'&oil='"+ddl7.SelectedItem.Text.ToString()+"'");
________________>>>>>>>>>>>>>>>>>>>>>>>>


string url = string.Format("http://localhost/sycar/cn/find2.aspx?type={0}",Server.HtmlEncode(ddl1.SelectedItem.Text)); //type is not required", in addition, Note that the parameters need to be encoded.
Response.Redirect(url);
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-11-27 09:30:02
| Show all posts
Upstairs is right, quotes are not allowed when passing parameters in the address bar
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list