I get this error when I clic开发者_如何学Gok on the href link: Microsoft JScript runtime error: The value of the property 'walkRedCarpet' is null or undefined, not a Function object.
To me, this means it is not firing the OnClientClick event and treating the OnClick like a clientside event.. am I wrong?
The link (a href) is programmatically generated from the codebehind PageLoad event and is the contents of a placeholder.
CODE
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MyFile.aspx.cs" Inherits="MyProject.MyFile" %>
<script runat="server">
protected void walkRedCarpet(int eventID)
{
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
function Call() {
return Page_ClientValidate();
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updtPnlRedCarpet" runat="server">
<asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
</asp:Content>
PLACEHOLDER CONTENTS CODEBEHIND
<a href='#' OnClick='walkRedCarpet(" + eventID + ");' OnClientClick='return Call()' runat='server' id='linkEventShowImageSet'><img Width='125' Height='95'src='Images/" + strEventThumb.ToString() + "' border='0'></a>
PLACEHOLDER CONTENTS POSTCOMPILE
<a href='#' OnClick='walkRedCarpet(1);' OnClientClick='return Call()' runat='server' id='linkEventShowImageSet'><img Width='125' Height='95'src='Images/event-1-ready.jpg' border='0'></a>
I am very new to AJAX. I have scoured the webbernet and looked at countless examples until my brain is very soft and mushy. Please be gentle.
I'm half asleep, my first read made me skip the "runat="server"" you have in there. You are right as to the behavior, so what does the generated HTML look like?
I had to actually use a LinkButton and this:
UpdatePanel1.UpdateMode = System.Web.UI.UpdatePanelUpdateMode.Conditional;
UpdatePanel1.Update();
to get it to work properly.
Good Luck!
精彩评论