Images in Search Results?

D

dvkintanar

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
 
K

kapilp

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;
}
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top