This is my first encounter with User Controls.
I have a user control that contains a jQuery function called Animate(). I want to call that function from an aspx page that contains the user control. Is that possible?
When I click the button in the following code the function is not fired and no error. What am I missing?
Upload_Animation.ascx
<head>
<script>
function AnimateGif() {
// do some stuff
}
</script>
</head>
<body>User Control</body>
aspx page
<head runat="server">
<uc:UploadAnimation ID="uc1" runat="server"/>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button OnClientClick="AnimateGif();" runat="server" Text="Do stuff" OnClick="btn_Click"/>
</div>
</form>
</body>
web.config
<controls>
<add tagPrefix="uc" src="~/UserControls/Upload_Animation.ascx" tagName="UploadAnimation" />
</controls>
First of all, I cannot see any JQuery code in your source example. As I can see (correct me if I'm wrong), you are trying to call client Javascript function that is declared as Animate() and you are calling as AnimateGif(); Try to correct the name of the calling function to match the declared name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.