函数返回值的问题
[bold]post.aspx:[/bold]<%@ Page Language="C#" AutoEventWireup="true" CodeFile="post.aspx.cs" Inherits="post" Debug="true" ValidateRequest="false"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www. >
<head runat="server">
<title>无标题页</title>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<form id=form2 runat="server">
<div align="center">
<table border="1" width="900" style="border-collapse: collapse" bordercolor="#F2F2F2" id="table1" bgcolor="#C0C0C0">
<tr>
<td align="right" style="height: 30px" colspan="2">
<img border="0" src="images/top.gif" width="900" height="150"></td>
</tr>
<tr>
<td align="right" style="height: 30px" colspan="2" bgcolor="#CC0000">?</td>
</tr>
<tr>
<td align="right" style="width: 131px;height: 30px"><font face="黑体">主题:</font></td>
<td align="left">
?<asp:TextBox ID="TextBox2" runat="server" Width="493px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 131px; height: 90px" valign="top"><font face="黑体" style="vertical-align: super">内容:</font></td>
<td style="height: 90px" align="left">
<textarea id="TextArea1" cols="20" name="tx" rows="2" style="display:none "><p style="background:EEff00"><%#showcontent()%></p></textarea> [bold]‘这里却得不到值,是什么问题?[/bold]
<IFRAME ID="eWebEditor1" src="edit/ewebeditor.asp?id=tx&style=s_coolblue" frameborder="0" scrolling="no" width="550" height="350">
</IFRAME></td>
</tr>
<tr>
<td align="left" colspan="2" style="height: 33px">
??<asp:Button ID="Button1" runat="server" Text="回复" Width="73px" OnClick="Button1_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
[bold]post.aspx:[/bold]
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class post : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie hc = Request.Cookies["name"];
string dbpath = "~/datebase/#bbs.mdb";
string strconn = "Provider = Microsoft.Jet.OleDb.4.0; Data Source=" + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]);
OleDbConnection sampleconn = new OleDbConnection(strconn);
sampleconn.Open();
OleDbCommand rs = new OleDbCommand("select * from content where id="+ Request.QueryString["id"], sampleconn);
OleDbDataReader rdr = rs.ExecuteReader();
try
{
while (rdr.Read())
{
TextBox2.Text="回复:"+rdr["title"].ToString();
}
}
finally
{
if (rdr != null)
{
rdr.Close();
}
}
string a;
a=showcontent(); [bold]'放在pageload这里却能得到值[/bold]
Response.Write(a);
}
[bold]public string showcontent() ’函数[/bold]
{
string dbpath = "~/datebase/#bbs.mdb";
string strconn = "Provider = Microsoft.Jet.OleDb.4.0; Data Source=" + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["dbPath"]);
OleDbConnection sampleconn = new OleDbConnection(strconn);
sampleconn.Open();
OleDbCommand rs = new OleDbCommand("select * from content where id=" + Request.QueryString["buse"] , sampleconn);
OleDbDataReader rdr = rs.ExecuteReader();
rdr.Read();
if (rdr.IsDBNull(0) == false)
{
Response.Write("中国大地");
return "您好";
}
else
{
Response.Write("haoa fdskjfk");
return "你好";
}
rdr.Close();
sampleconn.Close();
}
}
代码有点长,我删除掉了一些代码,我主要是想实现论坛中的引用效果,取得引用帖子的id后得到它的资料,显示在编辑框内。大家帮我看看,谢了,我在线等!
[[italic] 本帖最后由 xiaohonghui0 于 2007-12-18 13:56 编辑 [/italic]]