如何使用查询字符串C#ASP.NET将url图像传递给其他页面? [英] How pass url images to other pages with query string C# ASP.NET?
问题描述
listpage:
<%#string.Format(/ Views / Detail.aspx?id = {0}& cars_brand = {1}& cars_type = {2},
HttpUtility.UrlEncode(Eval(id)。ToString()),HttpUtility.UrlEncode(Eval(cars_brand)。ToString()),HttpUtility.UrlEncode(Eval(cars_type)) .ToString())
,HttpUtility.UrlEncode(Eval(cars_img1)。ToString()))
%>' >
DetailPage:
lblid.Text = HttpUtility.UrlDecode(Request.QueryString [ id]);
cars_brand.Text = HttpUtility.UrlDecode(Request.QueryString [ cars_brand]);
cars_type.Text = HttpUtility.UrlDecode(Request.QueryString [ cars_type]);
this .img.ImageUrl = 〜 / Content / Img / cars / + Request.QueryString [ cars_img1];
我的尝试:
如何使用查询字符串C#asp.net?
将url图像传递给其他页面您没有将cars_img1值添加到查询字符串中
<%# string .Format( / Views / Detail.aspx?id = {0}& cars_brand = {1}& cars_type = {2}& cars_img1 = {3} ,
HttpUtility.UrlEncode(Eval( id)。ToString( ),HttpUtility.UrlEncode(Eval( cars_brand)。ToString()),Http Utility.UrlEncode(Eval( cars_type)。ToString())
,HttpUtility.UrlEncode(Eval( cars_img1)。ToString()))
%> ' > 细节页面中缺少pre>
UrlDecode
this .img.ImageUrl = 〜/ Content / Img / cars / + HttpUtility.UrlDecode(Request.QueryString [ cars_img1] );
listpage:
<%# string.Format("/Views/Detail.aspx?id={0}&cars_brand={1}&cars_type={2}",
HttpUtility.UrlEncode(Eval("id").ToString()), HttpUtility.UrlEncode(Eval("cars_brand").ToString()), HttpUtility.UrlEncode(Eval("cars_type").ToString())
, HttpUtility.UrlEncode(Eval("cars_img1").ToString()) )
%>'>
DetailPage:
lblid.Text = HttpUtility.UrlDecode(Request.QueryString["id"]);
cars_brand.Text = HttpUtility.UrlDecode(Request.QueryString["cars_brand"]);
cars_type.Text = HttpUtility.UrlDecode(Request.QueryString["cars_type"]);
this.img.ImageUrl = "~/Content/Img/cars/" + Request.QueryString["cars_img1"];
What I have tried:
how pass url images to other pages with Query String C# asp.net?
You're not adding the cars_img1 value to the query string
<%# string.Format("/Views/Detail.aspx?id={0}&cars_brand={1}&cars_type={2}&cars_img1={3}", HttpUtility.UrlEncode(Eval("id").ToString()), HttpUtility.UrlEncode(Eval("cars_brand").ToString()), HttpUtility.UrlEncode(Eval("cars_type").ToString()) , HttpUtility.UrlEncode(Eval("cars_img1").ToString()) ) %>'>
UrlDecode
is missing in Details page
this.img.ImageUrl = "~/Content/Img/cars/" + HttpUtility.UrlDecode(Request.QueryString["cars_img1"]);
这篇关于如何使用查询字符串C#ASP.NET将url图像传递给其他页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!