将值发送到多个页面 [英] Sending values to multiple pages

查看:61
本文介绍了将值发送到多个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询,涉及从HOMEPAGE到背景中的2/3其他页面发布值。



例如:如果用户点击链接,则必须使用相同的值转到多个页面



用户点击链接X,它会发布值x = 1,y = 2,z = 3



所以在HOMEPAGE中我们得到这些值x = 1,y = 2,z = 3



现在我想要相同的值

I have a query related to posting values from HOMEPAGE to 2/3 other pages in background.

e.g.: If user clicks on a link the same values must go to multiple pages

User clicks on a link X which will post values x=1, y=2, z=3

So in HOMEPAGE we get these values x=1, y=2, z=3

NOW I want the same values

x=1, y=2, z=3

可在网站的其他页面中找到page1.aspx.cs和page2.aspx.cs



那么如何将值从主页传递到Page1.aspx.cs和page2.aspx.cs





我已经尝试过了使用来自主页的session / response.write发送,但是这些值在Page1.aspx.cs和page2.aspx.cs中不可用



在第2页

to be available in other pages of the site page1.aspx.cs and page2.aspx.cs

So how can i pass values from Homepage to Page1.aspx.cs and page2.aspx.cs


I've already tried sending using session / response.write from the homepage, but the values are not available in Page1.aspx.cs and page2.aspx.cs

In page 2

protected void Page_Load(object sender, EventArgs e)
{
    Response.Clear();
    Response.Write("Ths is the response from two.aspx: " + Request.Form["MyData"]);
    Response.End();
}





我在page1.aspx.cs或page2.aspx.cs中看到的值我看到MYdata =默认页面中NULL









Where I see the value in page1.aspx.cs or page2.aspx.cs I see MYdata= " " NULL

in Default page

<asp:TextBox ID="txtData" runat="server" />
<asp:Button ID="cmdSend" Text="Send" runat="server" />
<div id="resulta"></div>
<div id="resultb"></div>
 
<script type="text/javascript">
    function sendData(txt)
    {
        var c = $("#" + txt);
 
        makeCall("<%=Page.ResolveUrl("~/one.aspx") %>", c.val(), $("#resulta"));
        makeCall("<%=Page.ResolveUrl("~/two.aspx") %>", c.val(), $("#resultb"));
 
        return false;
    }
 
    function makeCall(url, text, target)
    {
        $.ajax({
            type: "POST",
            url: url,
            data: { myData: text },
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            dataType: "text",
            success: function (data) {
                target.html(data);
            }
        });
 
    }
</script>

推荐答案

+ txt);

makeCall( <%= Page.ResolveUrl(〜/ one.aspx )%>,c.val(),
("#" + txt); makeCall("<%=Page.ResolveUrl("~/one.aspx") %>", c.val(),


#resulta));
makeCall( <%= Page.ResolveUrl(〜/ two.aspx < span class =code-string> )%>,c.val(),
("#resulta")); makeCall("<%=Page.ResolveUrl("~/two.aspx") %>", c.val(),


#resultb));

return false ;
}

函数makeCall(url,text,target)
{
("#resultb")); return false; } function makeCall(url, text, target) {


这篇关于将值发送到多个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆