ASP.NET -> How to POST data to the form such that images are displayed

巧了我就是萌 提交于 2019-12-12 03:59:06

问题


Scenario : ASP.NET site has a page named ShowDesign.aspx.

ASPX page has lot of controls. I have a DIV tag and I load the images in code behind. DIV is defined something like below in the ASPX.

<div id="pImageHolder" runat="server"></div>

Below is the code behind that loads images.

    protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    //Loop inside PreviewImages which has lots of images.
    foreach (String imgFile in this.PreviewImages)
    {
        Image pImage = new Image();

        pImage.ImageUrl =  imgFile; //URL length is longer. Do something.

        this.pImageHolder.Controls.Add(pImage);
    }
}

Update : Jun 1,2012 -> I have updated this question with more clarity as to what I am trying to do.

In OnInit(), I get the URL of the image (in the above loop). Every image will have unique URL.

Since the URL length of every image is longer, it doesn't display. The solution to this issue seems to be POSTING data to the form. The data that needs to be POSTED will be the URL contents.

The URL contains lot of '&' and I need to submit the contents of each '&' to the form. Don't know if I need to use AJAX or Jquery here.

I need some help here to achieve the above.

Hope my question is clear. If not, please let me know.


回答1:


According to latest comments, this question history and at the end you want post data to another url and get response html. Try this (I snipped your original url from previous question since is really big):

  string strangeUrl = "http://example.com/is/m//company1/Rec-Sc-105-QL2?setAttr.safe={visible=false}&setAttr.insertedTextPlaceholder={visible=false}";
  string data = strangeUrl.Substring(strangeUrl.IndexOf("?") + 1);

  WebClient wc = new WebClient();
  wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
  string result = wc.UploadString("www.example.com/addres-for-post.aspx", data);


来源:https://stackoverflow.com/questions/10745952/asp-net-how-to-post-data-to-the-form-such-that-images-are-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!