怎么能不跳转页面调用一个页面让期代码执行
比如http://localhost/sroweb/sroEvent/xunyou/xunyou.aspx
调用这个页面但是不跳转到他还让页面里的sql语句注入了两个页面不在同一个虚拟目录下

解决方案 »

  1.   

    string youraddr="xxx.aspx?yourdata="+xxxx;
    string outpage="<iframe width='0px' height='0px' style='display:none'  src='" + youraddr+ "'/>");
    Response.Write(outpage);
      

  2.   

    如果需要打开新窗口:
    string youraddr="xxx.aspx?yourdata="+xxxx;
    string outpage="<javascript>window.open('"+ youraddr+ "');</javascript>");
    Response.Write(outpage);
      

  3.   


    把http://localhost/sroweb/sroEvent/xunyou/xunyou.aspx页面需要执行的代码,提炼到一个web server里
      

  4.   

    你的WinForm实现ICallbackEventHandler接口,有两个函数RaiseCallbackEvent和GetCallbackResult,分别用于接收客户端调用和向客户端发送数据。这个过程是不刷新页面的,类似AJAX,如下:public partial class Login : System.Web.UI.Page, ICallbackEventHandler
    {
    protected string returnValue; protected void Page_Load(object sender, EventArgs e)
    {
    string cbReference = ClientScript.GetCallbackEventReference(this, "val", "ReceiveServerData", "context");
    string callbackScript = "function CallServer(val, context) { " + cbReference + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
    } public void RaiseCallbackEvent(string eventArgument)
    {
    if (eventArgument.StartsWith("cmd"))
    {
    returnValue = "NO"; string cmd = eventArgument.Split('|')[1]; if (cmd.Length > 4)
    {
    string id = cmd.Substring(0, 4);
    string password = cmd.Substring(4); DataSet ds = CGlobal.GetData(
    @"DECLARE @iPersonID AS int
                            DECLARE @cPassword AS varchar(30)                        SET @iPersonID = CAST('" + id + @"' AS int)
                            SET @cPassword = '" + password + @"'                        SELECT cName FROM tPerson WHERE iPersonID = @iPersonID AND cPassword = @cPassword                        SELECT MIN(dBeginDate), MAX(dEndDate) 
                            FROM tUnitPerson a
                            JOIN tUnit b ON a.iUnitID = b.iUnitID
                            WHERE a.iPersonID = @iPersonID AND a.bFinish = 0 AND b.dBeginDate <= GETDATE() AND DATEADD(DAY, 1, b.dEndDate) >= GETDATE()                        SELECT MIN(dBeginDate), MAX(dEndDate) 
                            FROM tUnitPerson a
                            JOIN tUnit b ON a.iUnitID = b.iUnitID
                            WHERE a.iPersonID = @iPersonID AND a.bFinish = 0"); if (ds == null)
    {
    returnValue = "数据库错误";
    return;
    } if (ds.Tables[0].Rows.Count == 0)
    {
    returnValue = "错误的账号或密码";
    return;
    } if (ds.Tables[1].Rows[0][0] == DBNull.Value)
    {
    if (ds.Tables[2].Rows[0][0] == DBNull.Value)
    {
    returnValue = "没有需要测评的项目";
    }
    else
    {
    returnValue = "超过有效的测评期限: 测评日期从 " + ((DateTime)ds.Tables[2].Rows[0][0]).ToString("yyyy-MM-dd") + " 至 " +
    ((DateTime)ds.Tables[2].Rows[0][1]).ToString("yyyy-MM-dd");
    } return;
    } Session["iPersonID"] = id;
    Session["cName"] = ds.Tables[0].Rows[0][0]; returnValue = "OK";
    }
    }
    } public string GetCallbackResult()
    {
    return returnValue;
    }
    }
    IE端分别对应的是CallServer函数和ReceiveServerData函数<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="WebTest.Login" %><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <script language="javascript" type="text/javascript">
    function login_onclick() {
    CallServer("cmd|" + document.getElementById("userID").value, "");
    return false;
    } function ReceiveServerData(val) {
    if (val == "OK")
    location = "PersonUnit.aspx";
    else
    alert(val);
    }
    </script>
    <style type="text/css">
    .style1
    {
    font-size: small;
    }
    .style2
    {
    color: #0000FF;
    }
    .style3
    {
    font-family: 仿宋_GB2312;
    }
    .style4
    {
    font-size: small;
    font-family: 宋体, Arial, Helvetica, sans-serif;
    }
    .style5
    {
    font-size: small;
    font-family: 仿宋_GB2312;
    }

    a
    {
    }
    </style>
    </head>
    <body oncontextmenu="self.event.returnValue=false;" onselectstart="return false;">
    <form id="form1" runat="server">
    <div style="width: 100%; height: 100%; text-align: center">
    <table style="width: 1024px; height: 768px; vertical-align: top; background-image: url('PAGE.JPG');"
    cellspacing="0" cellpadding="0">
    <tr style="height: 300px">
    <td style="width: 320px">
    &nbsp;
    </td>
    <td style="width: 110px">
    &nbsp;
    </td>
    <td style="width: 73px">
    &nbsp;
    </td>
    <td style="width: 521px">
    &nbsp;
    </td>
    </tr>
    <tr style="height: 33px">
    <td>
    &nbsp;
    </td>
    <td colspan="2" onclick="location='Proclamation.html';">
    &nbsp;
    </td>
    <td>
    &nbsp;
    </td>
    </tr>
    <tr style="height: 60px">
    <td colspan="4">
    &nbsp;
    </td>
    </tr>
    <tr style="height: 33px">
    <td>
    &nbsp;
    </td>
    <td colspan="2">
    <input style="border: 0px none #FFFFFF; width: 183px; height: 33px; text-align: left;
    vertical-align: bottom; font-size: 18px;" id="userID" type="text" /><input style="display: none"
    id="rtn" type="text" />
    </td>
    <td>
    &nbsp;
    </td>
    </tr>
    <tr style="height: 25px">
    <td colspan="4">
    &nbsp;
    </td>
    </tr>
    <tr style="height: 43px">
    <td colspan="2">
    &nbsp;
    </td>
    <td onclick="login_onclick();">
    &nbsp;
    </td>
    <td>
    &nbsp;
    </td>
    </tr>
    <tr style="height: 274px">
    <td colspan="4">
    &nbsp;
    </td>
    </tr>
    </table>
    </div>
    </form>
    </body>
    </html>