将数据从HTML传递到Aspx页面
下午好,
我想将数据从我的html页面传递到Aspx页面并呈现此HTML页面在运行时通过使用<! - #INCLUDE FILE =.. \\\\\\\\\\\\\\\在aspx源代码中。
在JavaScript文件中,我的方法是
Hi,
Good Afternoon,
I want to pass data from my html page to Aspx page and this HTML page is rendered into Aspx page at run time by using <!--#INCLUDE FILE="..\HTML\GroupRegistration.html"--> in aspx source.
In JavaScript file my method is
$(document).ready(function ()
{
$("#btnSave").click(function () {
var GroupName = document.getElementById('txtGrpName').value;
var GroupType = document.getElementById('ddlGrpType').selectedIndex;
var GroupAddress = document.getElementById('txtAddress').value;
var FirstName = document.getElementById('txtFirstName').value;
试试{
$ .ajax({
类型:POST,
url:GroupRegistration.aspx,
data:{
param1 =:+ GroupName,param2 =:+ GroupType,param3 =:+ GroupAddress,param4 =:+ FirstName,},
try {
$.ajax({
type: "POST",
url: "GroupRegistration.aspx",
data: {
"param1=": +GroupName, "param2=": +GroupType, "param3=": +GroupAddress, "param4=": +FirstName, },
contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "html",
success: function (msg) {
},
error: function (xhr, status, error) {
alert('Error');
}
});
}
catch (e) {
alert(e);
}
});
});
我在aspx.cs文件中得到的值如下所示。
string txtGrpName = Request.Form [param1];
int ddlGrpType = Convert.ToInt32(Request.Form [param2]);
string txtAddress = Request.Form [param3];
string txtFirstName = Request.Form [param4];
然后在javascript中我得到的文件例外情况$未定义
那么请解决我的问题吗?
并解释传递数据的程序。
提前致谢
and I am getting the values in aspx.cs file like below.
string txtGrpName = Request.Form["param1"];
int ddlGrpType = Convert.ToInt32(Request.Form["param2"]);
string txtAddress = Request.Form["param3"];
string txtFirstName = Request.Form["param4"];
and then in javascript file I am getting exception "$ is undefined"
So please give solution to my problem?
And explain the procedure to pass data.
Thanks in advance
(文件).ready(function()
{
(document).ready(function () {
( # btnSave)。click(function(){
var GroupName = document.getElementById(' txtGrpName')。 value ;
var GroupType = document.getElementById(' ddlGrpType'跨度>)的selectedIndex。
var GroupAddress = document.getElementById(' txtAddress')。 value ;
var FirstName = document.getElementById(' txtFirstName')。 value ;
("#btnSave").click(function () { var GroupName = document.getElementById('txtGrpName').value; var GroupType = document.getElementById('ddlGrpType').selectedIndex; var GroupAddress = document.getElementById('txtAddress').value; var FirstName = document.getElementById('txtFirstName').value;
try {
try {
.ajax({
类型:POST,
url:GroupRegistration.aspx,
数据: {
param1 =:+ GroupName,param2 =:+ GroupType,param3 =:+ GroupAddress,param4 =:+ FirstName,},
.ajax({
type: "POST",
url: "GroupRegistration.aspx",
data: {
"param1=": +GroupName, "param2=": +GroupType, "param3=": +GroupAddress, "param4=": +FirstName, },
contentType: "application/x-www-form-urlencoded; charset=utf-8",
dataType: "html",
success: function (msg) {
},
error: function (xhr, status, error) {
alert('Error');
}
});
}
catch (e) {
alert(e);
}
});
});
我正在获取aspx.cs文件中的值,如下所示。
string txtGrpName = Request.Form [param1];
int ddlGrpType = Convert.ToInt32(Request.Form [param2]);
string txtAddress = Request.Form [param3] ;
string txtFirstName = Request.Form [param4];
然后在javascript文件中我得到异常
and I am getting the values in aspx.cs file like below.
string txtGrpName = Request.Form["param1"];
int ddlGrpType = Convert.ToInt32(Request.Form["param2"]);
string txtAddress = Request.Form["param3"];
string txtFirstName = Request.Form["param4"];
and then in javascript file I am getting exception "