| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1026 人关注过本帖
标题:函数返回值的问题
取消只看楼主 加入收藏
xiaohonghui0
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2006-4-10
收藏
 问题点数:0 回复次数:1 
函数返回值的问题
[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]]
搜索更多相关主题的帖子: 返回值 函数 
2007-12-18 13:45
xiaohonghui0
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2006-4-10
收藏
得分:0 
自己回答,把post.aspx里面的 <%#showcontent()%>改为 <%=showcontent()%>

曾用asp做过公司管理系统,新闻发布系统,个人网站之类,可代做网站 有意者请联系我,电话:13714123661
2007-12-18 14:45
快速回复:函数返回值的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.040305 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved