Images in Search Results?

Discussion in 'ASP .Net Mobile' started by dvkintanar@gmail.com, Mar 26, 2006.

  1. Guest

    Hi, I'm trying to write a simple mobile search site that has thumbnails
    in the search results. I've tried building the search results using
    several different mobile controls, but I haven't had any success so
    far.

    The <mobile:Label> uses html codes for all of the special characters,
    so my image tags get printed out instead of showing the image.

    The <mobile:TextView> just ignores image tags.

    I've tried a couple other, but basically nothings worked for me thus
    far.




    Could anyone help me out here? I just need a way to build the search
    results html so that the image tags (and others) get recognized and
    rendered correctly.




    Thanks,
    Dustin
     
    , Mar 26, 2006
    #1
    1. Advertising

  2. kapilp Guest

    I had a similar issue and I had to create an custom control to do this. Here
    is the code for it. look it over. it works.

    public partial class SearchResults :
    System.Web.UI.MobileControls.MobileUserControl
    {
    private DataTable mSearchData = null;
    private int mTotalFound = 0;

    public DataTable SearchData
    {
    get
    {
    return this.mSearchData;
    }
    set
    {
    this.mSearchData = value;
    }
    }

    public int TotalFound
    {
    get
    {
    return this.mTotalFound;
    }
    set
    {
    this.mTotalFound = value;
    }
    }

    public override void DataBind()
    {
    if (this.mSearchData != null)
    {
    if (this.mSearchData.Rows.Count > 0)
    {
    this.lblResultCount.Text = this.mTotalFound.ToString() + "
    flingers found.";
    this.lblDisplayedCount.Text =
    this.mSearchData.Rows.Count.ToString() + " displayed.";
    for (int i = 0; i < this.mSearchData.Rows.Count; i++)
    {
    // setup some needed variables
    string ImageID =
    this.mSearchData.Rows["ImageID"].ToString();
    string iVal = i.ToString();
    string ProfileID =
    this.mSearchData.Rows["ProfileID"].ToString();
    // if there is an image to show the add the image control
    if (!String.IsNullOrEmpty(ImageID))
    {
    SqlImage MyImage = new SqlImage();
    MyImage.ID = "SqlImage" + iVal;
    MyImage.ImageID = Convert.ToInt32(ImageID);
    MyImage.EnableCaching = true;
    MyImage.CacheDuration = 120;
    this.Controls.Add(MyImage);
    }
    // setup the screen name label
    System.Web.UI.MobileControls.Label lblScreenName = new
    System.Web.UI.MobileControls.Label();
    lblScreenName.ID = "lblScreenName" + iVal;
    lblScreenName.StyleReference = "Label";
    lblScreenName.Text =
    this.mSearchData.Rows["ScreenName"].ToString();
    this.Controls.Add(lblScreenName);
    // setup the information label
    System.Web.UI.MobileControls.Label lblInfo = new
    System.Web.UI.MobileControls.Label();
    lblInfo.ID = "lblInfo" + iVal;
    lblInfo.StyleReference = "Label";
    lblInfo.Text =
    this.mSearchData.Rows["Age"].ToString() + " - " +
    this.mSearchData.Rows["Gender"].ToString() + " - " +
    this.mSearchData.Rows["CityProvince"].ToString() + ", " +
    this.mSearchData.Rows["StateCode"].ToString();
    this.Controls.Add(lblInfo);
    // setup the view profile link
    System.Web.UI.MobileControls.Link lnkProfile = new
    System.Web.UI.MobileControls.Link();
    lnkProfile.ID = "lnkProfile" + i.ToString();
    lnkProfile.StyleReference = "Link";
    lnkProfile.Text = "View Profile";
    lnkProfile.NavigateUrl =
    "~/Unauthenticated/ViewProfile.aspx?ProfileID=" +
    this.mSearchData.Rows["ProfileID"].ToString();
    this.Controls.Add(lnkProfile);
    if (i < this.mSearchData.Rows.Count - 1)
    {
    System.Web.UI.MobileControls.Image Line = new
    System.Web.UI.MobileControls.Image();
    Line.ID = "imgLine" + iVal;
    Line.ImageUrl = "~/Images/BlackLine.jpg";
    this.Controls.Add(Line);
    }
    }
    }
    else
    {
    this.lblResultCount.Text = "No flings found.";
    this.lblDisplayedCount.Visible = false;
    }
    }
    else
    {
    this.lblResultCount.Text = "No flings found.";
    this.lblDisplayedCount.Visible = false;
    }
    }
    }
     
    kapilp, Mar 29, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Monique Y. Mudama
    Replies:
    1
    Views:
    457
    Monique Y. Mudama
    Jun 28, 2005
  2. lovecreatesbeauty
    Replies:
    8
    Views:
    1,661
    Old Wolf
    Sep 12, 2005
  3. Ken Fine
    Replies:
    3
    Views:
    540
    Steven Cheng [MSFT]
    Jul 23, 2008
  4. Abby Lee
    Replies:
    5
    Views:
    421
    Abby Lee
    Aug 2, 2004
  5. Craig Keightley
    Replies:
    10
    Views:
    261
    Craig Keightley
    Jun 29, 2005
Loading...

Share This Page