您的位置:首页 > 其它

办公系统的学习(手动调用在线人数减一;两个打开页面如何传值,等)

2014-04-22 14:54 351 查看

手动调用在线人数减一:

Session.Abandon();(手动清空session)即可调用Session_End方法

两个打开页面如何传值

第一种方法:

父窗口: function A() {

var pageUrl = "WebForm4.aspx";

var arg = "dialogHeight:200;dialogWidth:200;center:yes;resizable:no;help:no;status:no;scroll:no;";

var vReturnValue = window.showModalDialog(pageUrl, arg);

alert("子页面传递过来的参数:" + vReturnValue);

}

子窗口: function A() {

window.returnValue = 'ddd';

window.close();

}

第二种方法:

父窗口: function A() {

var pageUrl = "WebForm4.aspx";

var arg = "dialogHeight:200;dialogWidth:200;center:yes;resizable:no;help:no;status:no;scroll:no;";

window.open(pageUrl, arg);

子窗口: window.opener.document.getElementById('Text1').value = 'ssss';

Text1是父窗口中的文本框。

子页面的打开方法是由:

ifeam的src属性,如何为指定的页面传递本页面lable的值,即将后台数据作为参数传递。

<iframe id="shou" name="aaa" src="DUxiaoxi.aspx?Name1=<%=Recived()%>" scrolling="auto" frameborder="0" ></iframe>

protected void Page_Load(object sender, EventArgs e)

{

if(!IsPostBack)

{

Label2.Text=Request.QueryString["id"];

}

}

public static string Recived(){

return HttpContext.Current.Request.QueryString["id"].ToString();

}

例子2:AJAX传递参数

后台:

public string AddressName = "";

protected void Page_Load(object sender, EventArgs e)

{

if(!IsPostBack)

{

if (Session["TeacherId"] != null)

{

AddressName=Request.QueryString["AddressId"].ToString();

}

else

{

Response.Redirect("Login.aspx");

}

}

}

前台:

$.ajax({

url: "ChatService.asmx/GetText",

data: "{AddressId:'<%=AddressName%>'}",

type: "post",

contentType: "application/json",

success: function (data) {

$('#divshowinfo table').remove()

$('#divshowinfo').append(data.d);

}, error: function () {

// alert("操作失败");

}

})

querystring乱码

string str= HttpUtility.UrlEncode("中文"); //先编码

string str1 = HttpUtility.UrlDecode(str);//后解码

Response.Redirect如何将页面显示在另一个窗口

public class RedirectHelper

{

public static void Redirect(string url,

string target, string windowFeatures)

{

HttpContext context = HttpContext.Current;

if ((String.IsNullOrEmpty(target) ||

target.Equals("_self", StringComparison.OrdinalIgnoreCase)) &&

String.IsNullOrEmpty(windowFeatures))

{

context.Response.Redirect(url);

}

else

{

Page page = (Page)context.Handler;

if (page == null)

{

throw new

InvalidOperationException("Cannot redirect to new window.");

}

url = page.ResolveClientUrl(url);

string script;

if (!String.IsNullOrEmpty(windowFeatures))

{

script = @"window.open(""{0}"", ""{1}"", ""{2}"");";

}

else

{

script = @"window.open(""{0}"", ""{1}"");";

}

script = String.Format(script, url, target, windowFeatures);

page.ClientScript.RegisterStartupScript(page.GetType(),

"Redirect", script, true);

}

}

}

调用: RedirectHelper.Redirect("WebXianShiGongGao.aspx?from=" + theme + "", "_blank", "");

GridView可以对绑定的字段进行样式修改,编辑列——》选择BoundField这个样式(或其他的样式)——》属性中的数据下的DataFormatString可以对绑定的字段进行格式设置。例如日期;数据库(2014-02-04:0:00:00)显示的时候可以将时分秒去掉。即上面属性设置为:{0:yyyy-MM-dd}

可以查询GridView中的数据。this.GridView1.Rows[0].Cell[1].Text


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐