Argentini.Halide.H3ClientSide.CreateJsonIdArray C# (CSharp) Method

CreateJsonIdArray() public static method

Insert a script block which creates a JSON object with an array of client control ID names for all server-side controls. This allows access to the objects using javascript. It is best used in the Page_PreRender block. using Argentini.Halide; ... H3ClientSide.CreateJsonIdArray(MyPanel, "en", H3ClientSide.JsonObjectMode.ByID); Assuming that there is a server-side control on the page, with the ID "Control01", its run-time ID is something cryptic, like "ctl00_Body_Control01". After the code above is executed, however, Javascript code on the page itself can refer to all server-side controls by their server-side ID's, as: var obj = document.getElementById(en.Control01); $(en.Control01).value = "test";
public static CreateJsonIdArray ( Page pageObject, Control containerControl, string objectName, JsonObjectMode mode ) : void
pageObject System.Web.UI.Page The Page object.
containerControl System.Web.UI.Control The container for which all children should be used.
objectName string Name for the object with the array of names.
mode JsonObjectMode JsonObjectMode enumeration which specifies how page /// objects are to be identified; by ID or CSS class name.
return void
        public static void CreateJsonIdArray(Page pageObject, Control containerControl, string objectName, JsonObjectMode mode)
        {
            if (objectName.Contains(" "))
            {
                throw new Exception("CreateJsonIdArray objectName cannot contain spaces");
            }

            else
            {
                counter = 0;
                string script = en(containerControl, mode);
                pageObject.ClientScript.RegisterClientScriptBlock(typeof(Page), objectName, objectName + "={" + script + "};", true);
            }
        }

Same methods

H3ClientSide::CreateJsonIdArray ( Page page, string objectName, JsonObjectMode mode ) : void