asp.net AJAX+JS

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by Alv, 20 Jul 2010.

  1. Alv

    Alv Elder - Старейшина

    Joined:
    30 Jan 2007
    Messages:
    0
    Likes Received:
    20
    Reputations:
    2
    Нужно, что бы обновлялось 2 поля. Одно через AJAX, другое через JS. Но AJAX затирает JS. Как тут поступить?
    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Label ID="ajax" runat="server" Text="ajax"></asp:Label>
                    <br />
                    <asp:Label ID="java" runat="server" Text="java"></asp:Label>
                    <br />
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" OnClientClick="document.getElementById('java').innerHTML = &quot;newJAVA&quot;;" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        </form>
    </body>
    </html> 
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebApplication4
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Button1_Click1(object sender, EventArgs e)
            {
                ajax.Text = "newAJAX";
                string JavaPost = @"document.getElementById('java').innerHTML = ""newJAVA"";";
                Button1.OnClientClick = JavaPost;
            }
        }
    
     
Loading...