将数据从HTML传递到Aspx页面 [英] Passing data from HTML to Aspx page

查看:160
本文介绍了将数据从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 "


这篇关于将数据从HTML传递到Aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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