Skip to content Skip to sidebar Skip to footer

ASP.Net With Javascript: Using Multiple Instances Of A Control In A Webform

I have a User Control which i want to use Multiple times on a page. So i tried the approach of moving the Control's JS into a File and creating a Prototype for it, so that it works

Solution 1:

Make the variable initializations after all scripts loaded like this (with JQuery):

$(document).ready(function()){
        var inst1 = new CtrlName<%=CtrlName1.ClientID %>();
        var inst2 = new CtrlName<%=CtrlName2.ClientID%>();

        function btnTest_ClientClick(strVal) {
            if (strVal == '1') {
                inst1.HidePanel();
                inst1.GetSearchedText();
                inst1.GetInputText();

            }
            else {
                inst2.HidePanel();
                inst2.GetSearchedText();
                inst2.GetInputText();
            }
            return false;
        }
};

Post a Comment for "ASP.Net With Javascript: Using Multiple Instances Of A Control In A Webform"