当前位置:编程学习 > C#/ASP.NET >>

关于ASP.NET的问题?

我在做一个系统的时候声明了一个单独的类,类中有一个方法:public static SqlDataReader CreateDataReader(string commandText)
    {
        try
        {
            SqlCommand command = new SqlCommand(commandText, CreateConnection());
            SqlDataReader reader = command.ExecuteReader();

              if(reader.Read())

              {

                 //弹出信息框!

                 //不是用Windows Form做的,而是用网站做的!

                 //求高手帮助   

              }
            return reader;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

追问:你的回答有问题!这个在aspx.cs里是这么写的!但是在类里是不能这么写的!
答案:你先在解决方案中右键相对应的类,然后,点添加引用,如图

在打开的窗口中选中System.Web,后点击OK,如图

然后在你的cs页面上加上空间命名:using System.Web;

在你代码中要弹出的地方写上:

在Response.Write();(你要弹出的信息)前加上HttpContext.Current.

即可弹出信息。

  应该这样写:

HttpContext.Current.Response.Write("<script>alert('a');</script>");

Resopnse.Write("<script language="javascript">alert(“弹出信息框”);</script>");

Response.Write("<script>alert('问题答案不正确!');</script>");

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('您的提示有问题!')", true);

或者这个

Response.Write("<script>alert('“+reader[0], reader[1], reader[2]...+”');gohistory(-1);</script>");

望采纳

上一个:asp。net下拉图片列表
下一个:ASP.net怎么连接数据库?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,