jQuery的自动完成的文本框不与更新面板使用ASP.NET工作 [英] jquery auto complete textbox is not working with update panel using ASP.NET

查看:99
本文介绍了jQuery的自动完成的文本框不与更新面板使用ASP.NET工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦jQuery的卸载如何重新加载

无法获取的结果更新更新面板。如何克服与更新面板jQuery的

 <%@页面语言=C#AutoEventWireup =真codeBehind =WebForm1.aspx.cs中继承=TPAppl.WebForm1%GT;<!DOCTYPE HTML>
< HTML LANG =ENGT&;
  < HEAD>
      <间的charset =UTF-8>
      <标题> jQuery用户界面自动完成 - 自定义数据和显示< /标题>
        <链接rel =stylesheet属性HREF =HTTP://$c$c.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css>
      &所述; SCRIPT SRC =HTTP://$c$c.jquery.com/jquery-1.11.2.js>&下; /脚本>
&所述; SCRIPT SRC =HTTP://$c$c.jquery.com/ui/1.11.4/jquery-ui.js>&下; /脚本>
     <脚本类型=文/ JavaScript的>
    $(函数(){
        初始化();
    });
    变种prmInstance = Sys.WebForms.PageRequestManager.getInstance();
    prmInstance.add_endRequest(函数(){
        //你需要在这里重新绑定你的jQuery事件
        初始化();
    });
    函数初始化(){
        VAR项目= [
{标签:AN-01,演员:布莱尔港},
{标签:AN-02,演员:汽车尼科巴}
        ];        $(#lstRTO)。自动完成({
            来源:项目,
            选择:函数(事件,UI){
                $(#lstRTO)VAL(ui.item.label)。
                返回false;
            }
        })
        .autocomplete(实例)._ renderItem =功能(UL,项目){
            返回$(<立GT;)
              .append(LT&; A><强>中+ item.label +< / STRONG> /+ item.actor +< / A>中)
              .appendTo(微升);
        };
    }
< / SCRIPT>
< /头>
 <车身=服务器>
      <形式=服务器>
       < ASP:的ScriptManager ID =ScriptManager1=服务器> < / ASP:ScriptManager的>
         < ASP:的UpdatePanel ID =UpdatePanel1=服务器>
              <&的ContentTemplate GT;
               < ASP:文本框ID =TextBox1中的AutoPostBack =真=服务器OnTextChanged =TextBox1_TextChanged>< / ASP:文本框>
              &所述;输入的id =lstRTO>
          < /&的ContentTemplate GT;
       < / ASP:的UpdatePanel>
   < /表及GT;
< /身体GT;

C#code如同

 使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;
使用System.Web.UI程序;
使用System.Web.UI.WebControls;命名空间TPAppl
{
    公共部分类WebForm1的:System.Web.UI.Page
    {
        保护无效的Page_Load(对象发件人,EventArgs的发送)
        {        }        保护无效TextBox1_TextChanged(对象发件人,EventArgs的发送)
        {
            TextBox1.Text = TextBox1.Text +123;
        }
    }
}


解决方案

这将帮助你。

 <脚本类型=文/ JavaScript的>
    功能页面加载(发件人,参数){
        如果(args.get_isPartialLoad()){
            $(函数(){
                初始化();
            });
        }
    }
< / SCRIPT>

Unable to get result Update panel is updated once jquery unloaded how to reload again. How to overcome the jquery with update panel

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TPAppl.WebForm1" %>

<!doctype html>
<html lang="en">
  <head>
      <meta charset="utf-8">
      <title>jQuery UI Autocomplete - Custom data and display</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
      <script src="http://code.jquery.com/jquery-1.11.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>


     <script type="text/javascript">
    $(function () {
        initializer();
    });


    var prmInstance = Sys.WebForms.PageRequestManager.getInstance();


    prmInstance.add_endRequest(function () {
        //you need to re-bind your jquery events here
        initializer();
    });
    function initializer() {
        var projects = [
{ "label": "AN-01", "actor": "Port Blair " },
{ "label": "AN-02", "actor": "Car Nicobar " }
        ];

        $("#lstRTO").autocomplete({
            source: projects,
            select: function (event, ui) {
                $("#lstRTO").val(ui.item.label);
                return false;
            }
        })
        .autocomplete("instance")._renderItem = function (ul, item) {
            return $("<li>")
              .append("<a><strong>" + item.label + "</strong> / " + item.actor + "</a>")
              .appendTo(ul);
        };


    }


</script>
</head>
 <body runat="server">
      <form runat="server">
       <asp:ScriptManager ID="ScriptManager1" runat="server">     </asp:ScriptManager>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
              <ContentTemplate>
               <asp:TextBox ID="TextBox1" AutoPostBack="true"  runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
              <input id="lstRTO">
          </ContentTemplate>
       </asp:UpdatePanel>
   </form>
</body>

C# Code Like

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TPAppl
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            TextBox1.Text = TextBox1.Text+"123";
        }
    }
}

解决方案

It will help you

<script type="text/javascript">
    function pageLoad(sender, args) {
        if (args.get_isPartialLoad()) {
            $(function () {
                initializer();
            });
        }
    }
</script>

这篇关于jQuery的自动完成的文本框不与更新面板使用ASP.NET工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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