如何将值从jquery传递给代码隐藏的VB.NET [英] How to pass a value from jquery to codebehind VB.NET

查看:68
本文介绍了如何将值从jquery传递给代码隐藏的VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,



您能否告诉我如何实现以下目标?



我有page1.aspx,其中有一个运行callback.html的iframe



在callback.html中我有一个字符串TESTPASSED



此字符串应传递给Page2.aspx



Page1.aspx - > callback.html - >

执行javascript Test()函数和传递字符串值 - > Page2.aspx



非常感谢您的帮助。



我的尝试:



Hello experts,

Can you please give me a gist on how to achieve below?

I have page1.aspx where in there is an Iframe that runs callback.html

In callback.html I have a string "TESTPASSED"

This string should be passed to Page2.aspx

Page1.aspx-->callback.html-->
Execute javascript Test() function and Pass string value --> Page2.aspx

Your help is much appreciated.

What I have tried:

Function Test(){
var jsonInput ="TESTPASSED";
    $.ajax(
                            { 
                                type: "POST",
                                dataType: "text json",
                               url: "Page2.aspx ",
    	                      data:"{mystring:"+jsonInput+"}",
                                contentType: 'application/json'
    });
	
}



And my Page2.aspx code behind is as below 

Public Class RequestResponse
    Public temp As String
End Class

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim resp As RequestResponse = New RequestResponse
Dim result as string = Request.Form("mystring")
//Not sure how to get the string value here TESTPASSED

End Sub

推荐答案

.ajax(
{
type:POST,
dataType:text json,
url :Page2.aspx,
数据:{mystring:+ jsonInput +},
contentType:'application / json'
});

}



我的Page2.aspx代码背后是

公共类RequestResponse
Public temp As String
End Class

受保护的子Page_Load(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Load
Dim resp As RequestResponse = New RequestResponse
Dim result as string = Request.Form(mystring)
//不确定如何获取字符串值TESTPASSED

End Sub
.ajax( { type: "POST", dataType: "text json", url: "Page2.aspx ", data:"{mystring:"+jsonInput+"}", contentType: 'application/json' }); } And my Page2.aspx code behind is as below Public Class RequestResponse Public temp As String End Class Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim resp As RequestResponse = New RequestResponse Dim result as string = Request.Form("mystring") //Not sure how to get the string value here TESTPASSED End Sub


这对我有用。再次感谢F-ES Sitecore



This did the trick to me. thanks again F-ES Sitecore


.ajax(
{
类型:POST,
数据:'mystring ='+ myInput,
url:Page2.aspx,
成功:函数(结果){
debugger;
alert(success:+ JSON.stringify(myInput));
},
错误:function(xhr,status){
debugger;
alert(失败+状态;
}
});
.ajax( { type: "POST", data: 'mystring=' + myInput , url: "Page2.aspx", success: function (result) { debugger; alert("success :" + JSON.stringify(myInput)); }, error: function (xhr, status) { debugger; alert("fail " + status); } });


这篇关于如何将值从jquery传递给代码隐藏的VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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