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;
using System.Data.Sql;
using System.Data.SqlClient;public partial class MSGCONTROL2_Qf_login : System.Web.UI.Page
{
//protected string NewCode = "checkCode";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Panel1.Visible =false;
}
} private void Path()
{
Jxllt.DBUtility.DbHelperSQL.ConnDataBase("jxtmsg", "");
//Response.Write(Jxllt.DBUtility.DbHelperSQL.connectionString.ToString());
//Response.End();
SqlParameter[] dist ={
new SqlParameter("@empid",SqlDbType.VarChar,12),
new SqlParameter("@ret",SqlDbType.Int)
};
dist[0].Value = this.txtUser.Text.Trim().ToString();
dist[1].Direction = ParameterDirection.Output;
SqlDataReader sdr = Jxllt.DBUtility.DbHelperSQL.RunProcedure("Qf_MobilePath", dist);
//this.LblPath.Text = "消息通道是:"+dist[1].Value.ToString();
this.HidPath.Value = dist[1].Value.ToString();
}
protected void BtnMobile_Click(object sender, EventArgs e)
{ if (txtUser.Text.Trim().ToString() == "")
{
Response.Write("用户名不能为空!请输入正确的用户名");
}
else
{ try
{
Jxllt.DBUtility.DbHelperSQL.ConnDataBase("jxtmsg", "");
SqlParameter[] list ={ new SqlParameter ("@mobile",SqlDbType.VarChar,12),
new SqlParameter("@Empid",SqlDbType.VarChar,12),
new SqlParameter("@path",SqlDbType.VarChar,50),
new SqlParameter("@msgcontent",SqlDbType.VarChar,100),
new SqlParameter("@Ret",SqlDbType.Int)
};
list[0].Value = null;
list[1].Value = this.txtUser.Text.Trim().ToString();
list[2].Value = this.HidPath.Value.ToString();
list[3].Value = Request.Cookies["CheckCode"].Value.ToString();
list[4].Direction = ParameterDirection.Output;
Jxllt.DBUtility.DbHelperSQL.RunProcedure("Qf_Getcheckcode", list);
Response.Write("<script>alert('获取成功');</script>");
}
catch (System.NullReferenceException ee)
{
Response.Write(ee.Message);
}
} }
}
当我在运行这段代码的时候他会报错说未将对象应用到实例的错误,我知道问题出在list[3].Value = Request.Cookies["CheckCode"].Value.ToString();当我把this.Panel1.Visible =false;设为true的时候就不会出现这个 ,但是我现在要的效果就是不让他显示在页面上 ,有没有人能告诉我这个应该怎么解决
var oDiv = document.getElementById( sDivId );
if( oDiv != undefined ) oDiv.style.display = "none";
}
function showDiv( sDivId ){
var oDiv = document.getElementById( sDivId );
if( oDiv != undefined ) oDiv.style.display = "";
}后台可以用这两句来决定显示与否。
Page.ClientScript.RegisterClientScriptBlock(GetType(), "hide_id", "<script>hideArea('id');</script>");//隐藏
Page.ClientScript.RegisterClientScriptBlock(GetType(), "show_id", "<script>showArea('id');</script>");//显示