con是一个参数,我想通过con传递一个DIV的ID值进去,然后返回,该怎么改啊!
protected void MarkLink(Object con)
{
string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
string result1 = "";
List<listParam> list = GetList();
foreach (listParam lp in list)
{
result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
}
return con.InnerHtml = result1;
}
protected void MarkLink(Object con)
{
string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
string result1 = "";
List<listParam> list = GetList();
foreach (listParam lp in list)
{
result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
}
return con.InnerHtml = result1;
}
错误 34 “object”不包含“InnerHtml”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“InnerHtml”(是否缺少 using 指令或程序集引用?) i:\mysql\App_Code\Class1.cs 83 19 i:\mysql\
{
string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
string result1 = "";
List<listParam> list = GetList();
foreach (listParam lp in list)
{
result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
}
return con.InnerHtml = result1;
}
你看你的方法都没返回值。要么你用out 要么就加个返回值类型。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data;
using System.Configuration;
using MySql.Data;
using MySql.Data.MySqlClient;/// <summary>
///Class1 的摘要说明
/// </summary>
public class Class1
{
public Class1()
{
//
//TODO: 在此处添加构造函数逻辑
// public struct listParam
{
public string url
{
get;
set;
}
public string src
{
get;
set;
}
public string title
{
get;
set;
} }
/// <summary>
/// 读取数据库产品数据
/// </summary>
/// <returns></returns>
public List<listParam> GetList()
{
List<listParam> result=new List<listParam>();
listParam lp;
try
{
string conn = ConfigurationManager.ConnectionStrings["520tuanConnectionString"].ConnectionString;
MySqlConnection con = new MySqlConnection(conn);
con.Open();
string sql = "select * from product";
MySqlCommand cmd = new MySqlCommand(sql,con);
MySqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
lp = new listParam();
lp.url = "";
lp.src = reader["src"].ToString();
lp.title = reader["title"].ToString();
result.Add(lp);
}
reader.Close();
con.Clone();
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
return result;
} protected void MarkLink( out Object con)
{
string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>价格:<b></b>{6} 元<BR></P></LI>";
string result1 = "";
List<listParam> list = GetList();
foreach (listParam lp in list)
{
result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
}
return con.InnerHtml = result1;
}
}
}
protected void MarkLink(HtmlGenericControl str)
{
string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
string result1 = "";
List<listParam> list = GetList();
foreach (listParam lp in list)
{
result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title); }
//str = new HtmlGenericControl();
str.InnerHtml = result1;
}
谢谢,各位的热心帮助与提醒。