English 中文(简体)
通行证 html 文本箱值,从jquery 模式到作为背后的编码
原标题:Pass html textbox value from a jquery modal to asp code behind

该代码显示一个Jquery dialog和一个html文本箱,在用户点击一个表格:button btn NewGroup后显示。

<script type="text/javascript" language="javascript">
function pageLoad(sender, args) {
    var $dialog = $( <div><fieldset><label for="name">Name</label><input type="text" name="Name" id="name" class="text ui-widget-content ui-corner-all" /></div> )
        .dialog({
            modal: true,
            autoOpen: false,
            title:  Enter New Group Name ,
            buttons: {
                 New : function () {
                    $(this).dialog( close );
                },
                Cancel: function () {
                    $(this).dialog( close );
                }
            }
        });


        $("#<%=btnNewGroup.ClientID %>").click(function () {
            $dialog.dialog( open );
            return true;
        });
}
</script>

<asp:Button ID="btnNewGroup" runat="server" Height="26px" 
onclick="btnNewGroup_Click" Style="margin-bottom: 0px" Text="New Group" 
ClientIDMode="Static" />

protected void btnNewGroup_Click(object sender, EventArgs e)
    {
        String t = Request.Form["Name"];
    }

当用户在对话中点击新纽子时,我想从文字箱中取名,并在我的代码中用该名称作为新的纽芬兰点击事件。

最佳回答

如果这是你所期望的,我并不真的相信,但你把姓名价值传给服务器边的网络方法。 利用Jquery s Ajax 履行纽托邦的职能。

在您的代码后面的服务器方面,你通过增加一个网络方法。

using System.Web.Services;

页: 1

[WebMethod]
public static void DoSomething(object name)
{
   //do something intersting
iii

Ajax电话将取代

 $(this).dialog( close );

你们现在在“新布顿”事件中用类似的东西点击。

var valFromNameBox = $("#name").val();
var jsonObj =  {name: "  + valFromNameBox +  "iii ;
var res;
$.ajax({
    type:  POST ,
    contentType:  application/json; charset=utf-8 ,
    data: jsonObj,
    dataType:  json ,
    url:  YourPage.aspx/DoSomething ,
    success: function (result) {
    iii,
    error: function (err) {
        alert(err.toString());
    iii
iii);

iii

问题回答

由于大家都准备好了投入控制,而且你担任了一个职务,你通常可以通过使用请求获得价值。 表格,如果是的话,该参数在编码上的价值就会落空。

Request.Form["Name"]

One note, remove the <form></form> from your dialogue, because you break the asp.net form and probably not work.

var $dialog = $( <div><fieldset><label for="name">Name</label>
<input type="text" name="Name" id="name" 
   class="text ui-widget-content ui-corner-all" /></fieldset></div> )




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签