如何使用查询字符串C#ASP.NET将url图像传递给其他页面? [英] How pass url images to other pages with query string C# ASP.NET?

查看:61
本文介绍了如何使用查询字符串C#ASP.NET将url图像传递给其他页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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()))
%> ' >


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆