views:

455

answers:

2

It is hitting the Page_Load event, but not the LinkButton's click :

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<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" UpdateMode=Conditional>
            <ContentTemplate>
                <asp:LinkButton ID="btnRenewAll" runat="server" onclick="LinkButton1_Click" OnClientClick="javascript:return ClientMe()">LinkButton</asp:LinkButton>
                <br />
                <asp:Label ID="lblMe" runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>



    </div>
    </form>
</body>

<script>
    function ClientMe() {
        var btnRenewall = document.getElementById('<%= btnRenewAll.ClientID %>');
        btnRenewall.disabled = true;
        alert("Hello");
        return true;
    }
</script>

</html>

CodeBehind :

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

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

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        lblMe.Text = "Checked";
        UpdatePanel1.Update();
    }
}
A: 

If you replace your JS with:

function ClientMe() {
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(startRequest);
    return true;
}

function startRequest(sender, e) {
    var btnRenewall = document.getElementById('<%= btnRenewAll.ClientID %>');
    btnRenewall.disabled = true;
    alert("Hello");
}

it should work. citing: link text

Kevin
A: 

Change this line:

 btnRenewall.disabled = 'disabled';

Here is a list of the minimized attributes in HTML and how they should be written in XHTML :

HTML        XHTML 
compact     compact="compact"
checked     checked="checked"
declare     declare="declare"
readonly    readonly="readonly"
disabled    disabled="disabled"
selected    selected="selected"
defer       defer="defer"
ismap       ismap="ismap"
nohref      nohref="nohref"
noshade     noshade="noshade"
nowrap      nowrap="nowrap"
multiple    multiple="multiple"
noresize    noresize="noresize"
rick schott