locked
Lightswitch custom code/control (NOT SILVERLIGHT) RRS feed

  • Question

  • Hi all,

    I am trying to find tutorial/info to read on how to add custom code/control to a lightswitch project but everything seems to force you down the SilverLight route which I do not want. What are the alternatives.

    What I want to achieve is quite simple a few textboxes, on a button click some info as saved in the database and some info is used to Perform API with a third party to automate sending of SMS e.t.c

    I just dont want to use Silverlight when it is used on fewer Browsers/Devices and appears to be being phased out.

    Thank you for any advice.

    Monday, July 13, 2015 8:04 PM

Answers

  • Hi Matt,

    Please try with JavaScript or JQuery to create custom control in the render event. Following code add a <b> label into screen.

    myapp.BrowseContacts.Contacts_render = function (element, contentItem) {
        // Instead of Screen, we passed Contacts as the contentItem. 
        var contacts = contentItem.value;
     
        // Set up the callback function to fire after the data is loaded.
        contentItem.dataBind("value.isLoaded", function ()
        {
            if (contacts.isLoaded) {
                //Create the HTML control
                var template = $("<b> " + contacts.count + " contacts found.</b>");
                //Append it to the DOM
                template.appendTo($(element));
            }
        });   
    };



    Best Regards,
    Weiwei
    • Marked as answer by Angie Xu Monday, July 27, 2015 2:08 AM
    Tuesday, July 14, 2015 8:38 AM
    Moderator

All replies

  • That would be the HTMLClient.

    Be ware, LightSwitch is as for now a framework on hold. But for your use it would suffice.

    Tuesday, July 14, 2015 8:08 AM
  • Hi Matt,

    Please try with JavaScript or JQuery to create custom control in the render event. Following code add a <b> label into screen.

    myapp.BrowseContacts.Contacts_render = function (element, contentItem) {
        // Instead of Screen, we passed Contacts as the contentItem. 
        var contacts = contentItem.value;
     
        // Set up the callback function to fire after the data is loaded.
        contentItem.dataBind("value.isLoaded", function ()
        {
            if (contacts.isLoaded) {
                //Create the HTML control
                var template = $("<b> " + contacts.count + " contacts found.</b>");
                //Append it to the DOM
                template.appendTo($(element));
            }
        });   
    };



    Best Regards,
    Weiwei
    • Marked as answer by Angie Xu Monday, July 27, 2015 2:08 AM
    Tuesday, July 14, 2015 8:38 AM
    Moderator
  • Thank you
    Tuesday, July 14, 2015 8:41 AM
  • Thank you
    Tuesday, July 14, 2015 8:41 AM