Javascript functions inside ASP.NET User Control

后端 未结 3 1187
逝去的感伤
逝去的感伤 2020-12-09 11:03

I created ASP.NET user control with javascript function :

<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"TestControl.ascx.cs\" Inherits         


        
3条回答
  •  悲哀的现实
    2020-12-09 11:15

    You need to use this.id

    $(document).ready(function () {
        load_v<%= this.ID %>    
    });
    
    function load_v<%= this.ID %>(fromclick) {
        alert('anything');
    }
    

    So that even if you need two or more same controls in the same page they will have different ids. Hope this Helps! cheers :)

提交回复
热议问题