跪求各位大虾,有个问题困扰了我n天了,就是后台服务端和前台的交互
我这里先有礼了
我有一个框架
有两个页面组成
<head>
<TITLE>页脚框架集</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</head>
<frameset rows="*,64">
<frame name="main" src="">
<frame name="footer" src="WebForm1.aspx" noResize scrolling="no">
<noframes>
<pre id="p2">
部分代码如上,一个页面是main另一个是footer
我想点击webForm1.aspx上一个按钮,并且在这个页面中保留一个Session变量,这个变
量是字符串型,这个字符串存储的是一个url地址
我想点击这个按钮的时候就用这个地址刷新frame名字main的那个页面
webform1.aspx页面的html代码是
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="SendArcXML.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title></title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript">
fuction confirmSubmit()
{
}//我主要是不会写这段script代码
我不知道怎么写,怎么去实现刷新那个另外一个页面,用一个Session变量存储的URL地址
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server"> ArcIMS服务器名称
</asp:label><asp:textbox id="ArcIMSServerText" style="Z-INDEX: 102; LEFT:
168px; POSITION: absolute; TOP: 16px"
runat="server">localhost</asp:textbox><asp:button
id="GetServicesButton" style="Z-INDEX: 103; LEFT: 344px; POSITION:
absolute; TOP: 16px"
runat="server" Text="获取服务"></asp:button><asp:label
id="ServiceNameLabel" style="Z-INDEX: 104; LEFT: 440px; POSITION: absolute;
TOP: 16px"
runat="server" Visible="False"> 服务名称</asp:label><asp:dropdownlist
id="ServiceDDList" style="Z-INDEX: 105; LEFT: 528px; POSITION: absolute;
TOP: 16px"
runat="server" Visible="False"
Width="120px"></asp:dropdownlist><asp:button id="ConfirmServiceButton"
style="Z-INDEX: 106; LEFT: 672px; POSITION: absolute; TOP: 16px"
runat="server" Text="确定" Visible="False"></asp:button></FONT></form>
</body>
</HTML>
webform1.aspx的后台是
后台代码是
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
namespace SendArcXML
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox ArcIMSServerText;
protected System.Web.UI.WebControls.Button GetServicesButton;
protected System.Web.UI.WebControls.Label ServiceNameLabel;
protected System.Web.UI.WebControls.DropDownList ServiceDDList;
protected System.Web.UI.WebControls.Button ConfirmServiceButton;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
ConfirmServiceButton.Attributes.Add("onClick", "return confirmSubmit();");//在这里我想绑定我想在Script里面写的方法,只要一点击,就运行那个函数
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.GetServicesButton.Click += new System.EventHandler(this.GetServicesButton_Click);
this.ServiceDDList.SelectedIndexChanged += new System.EventHandler(this.ServiceDDList_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void GetServicesButton_Click(object sender, System.EventArgs e)
{
try
{
localhost.ArcXML_Web_Service getReturnArcXML = new localhost.ArcXML_Web_Service();
string returnedArcXML = getReturnArcXML.sendMyArcXML("<GETCLIENTSERVICES/>", ArcIMSServerText.Text,"catalog","");
ArrayList theArrayList = new ArrayList();
int theEnd = 0;
string theService;
int theStart=returnedArcXML.IndexOf("SERVICE");
while (theStart > -1)
{
theStart = returnedArcXML.IndexOf("SERVICE name=",theEnd) + 14;
if (theStart < theEnd) break;
theEnd = returnedArcXML.IndexOf("servicegroup",theStart) - 2;
theService = returnedArcXML.Substring(theStart,theEnd - theStart);
theArrayList.Add(theService);
}
ServiceNameLabel.Visible = Boolean.Parse("True");
ServiceNameLabel.Text = "服务名称";
theArrayList.Sort();
;
ServiceDDList.Visible = Boolean.Parse("True");
ServiceDDList.Items.Clear();
ServiceDDList.DataSource = theArrayList;
ServiceDDList.DataBind();
ConfirmServiceButton.Visible = Boolean.Parse("True");
}
catch
{
ServiceDDList.Visible = Boolean.Parse("False");
ConfirmServiceButton.Visible = Boolean.Parse("False");
ServiceNameLabel.Visible = Boolean.Parse("True");
ServiceNameLabel.Text = "没有发现服务或者服务器名称出现错误";
}
}
private void ServiceDDList_SelectedIndexChanged(object sender, System.EventArgs e)
{
string hostname,ServiceObjectName;
hostname = ArcIMSServerText.Text.ToString();
ServiceObjectName = ServiceDDList.SelectedItem.Text.ToString();
string str = "http://"+hostname+"/Website/"+ServiceObjectName+"/frame.htm";
Session["strurl"] = str;//我在这里设置了一个Session变量负责为刷新另外一个页面提供一个url地址
}
}
}