Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jojo Aquino
    @jfaquinojr
    help spread the good news that is dotvvm to our webforms brethren
    Tomáš Herceg
    @tomasherceg
    @jfaquinojr Oh, maybe we should make the error message more clear. However, thank you for your feedback, I am glad that you like DotVVM. If you need some swag for the event, let me know - we have some stickers, T-shirts and so on. :-)
    Jojo Aquino
    @jfaquinojr
    @tomasherceg I'm sure the local community here would love some swag!
    ezev123
    @ezev123
    Hello
    LennartFuehrer
    @LennartFuehrer
    Hello
    Is there some way of increasing the depth of serialization? I've got a list of items where each item has another list. 2nd list however always ends up empty
    Tomáš Herceg
    @tomasherceg
    @LennartFuehrer DotVVM doesn't limit serialization depth, having list of lists should be possible. Is the inner list a public property with get & set? The serialization ignores fields.
    LennartFuehrer
    @LennartFuehrer
    Shit, after looking it over like 3 times... they were fields, yup. I feel a little dumb now. Thanks
    mmitchell-w
    @mmitchell-w
    Hello. I'm having trouble showing an arbitrary number of custom markup controls based on the results of a database query.
    Default.dothtml has a code-only custom control (Page) that takes ViewModels[] as a DotvvmProperty. DefaultViewModel builds this array from the database query. Page's OnInit adds new instances of markup control classes to its Children property.
    Markup controls do not appear (no HTML rendered, no console errors), but code-only controls do appear. The ViewModel[] is correctly rendered to my __dot_viewmodel_root.
    Alternatively, how could I replace Page with a Repeater and Placeholder, and substitute that Placeholder with my markup control at runtime? In WebForms we could get a reference to the Placeholder in the codebehind, and "Controls.Add" from there.
    Tomáš Herceg
    @tomasherceg
    @mmitchell-w This can be done, but the process is not so straight-forward.
    Basically, you can add the ID="something" to any control in the page and then use Context.View.FindControlByUniqueId to look for the particular control. Then you can call control.Children.Add(your control).
    However, you'll need to set the correct DataContext to the control - you can look at how we dynamically generate data-binding expressions in DotVVM Dynamic Data (https://github.com/riganti/dotvvm-dynamic-data/blob/master/src/DotVVM.Framework.Controls.DynamicData/DynamicDataContext.cs) - there are methods which can construct binding expression from a string. You can then call yourControl.SetBinding(DataContextProperty, bindingExpression).
    All of this should be done in the Init or Load phase, before the commands from buttons and other controls are fired - the control tree must be complete after the Load phase ends.
    Let us know if you run into any issues - all these things are possible, but they are documented only briefly.
    mmitchell-w
    @mmitchell-w
    @tomasherceg Is this advice concerning the former method (code-only control to host markup controls) or the latter (Repeater/Placeholder on .dothtml)?
    Tomáš Herceg
    @tomasherceg
    @mmitchell-w It will suit better the first method, but the principle would be the same for the latter one - you'd need to find the Repeater by ID and then look inside and build the controls for the individual items. But it looks easier to skip the Repeater and generate the controls yourself.
    Lubos
    @tatran_twitter
    Is there a RADIOBUTTON example where this is used in a grid? Or how do I set CheckedValue when options are true/false?
    image.png
    Jan Berger
    @kamm85

    Hello, Is there any way to get a value binding from Viewmodel method?
    e.g. for this:

    <dot:Panel Visible="{value: _root.IsExpanded(_this.ID) == false}">
    waiting
    </dot:Panel>

    Thank you

    Stanislav Lukeš
    @exyi
    @kamm85 Not easily. Value bindings are translated to a Javascript expression and DotVVM would have no idea how to translate your method.
    You can probably set a property in the ViewModel whenever you are changing the "expanded state" and bind it to the variable.
    It is also possible to instruct DotVVM how to translate this specific method, but I think that you don't want to do that.
    Jan Berger
    @kamm85

    @exyi Thanks for your suggestion. <dot:Panel> component is in <dot:repeater>... I resovle it with extending RepeaterListDTO (repeater datacontext) with property DataLoaded and assigning this property in viewmodel on relevant commands..

    Suggestion for others:

    <dot:Repeater datacontext="{value: _root.RepeaterListDTO}">
        <ItemTemplate>
            <dot:Panel Visible="{value: !_this.OnDemand.DataLoaded}">
                Please, wait...
             </dot:Panel>
              <dot:Panel Visible="{value: _this.OnDemand.DataLoaded}">
                   {{value: _this.Name}}
                     ...loaded content
               </dot:Panel>
        </ItemTemplate>
    </dot:Repeater>

    Have a nice day

    gkumik9
    @gkumik9

    Hello, I have a problem with the grid. If I add a column 'DateTime', an error occurs:

    Error: Unable to process binding "if: function(){return dotvvm.isSpaReady }"
    Message: Unable to process binding "withGridViewDataSet: function(){return AccountsGrid }"
    Message: Unable to process binding "foreach: function(){return dotvvm.evaluator.getDataSourceItems($gridViewDataSet) }"
    Message: Unable to process binding "text: function(){return dotvvm.globalize.formatString("",DateCreate) }"
    Message: Resource 'globalize' is not included (symbol 'dotvvm_Globalize' could not be found).
    It is usually included automatically when needed, but sometime it's not possible, so you will have to include it in your page using '<dot:RequiredResource Name="globalize" />'

    Tomáš Herceg
    @tomasherceg
    @gkumik9 This was fixed in DotVVM 2.4.0-preview01 - DotVVM doesn¨t add necessary scripts for the formatting to work.
    In older versions of the framework, you need to add this code in PreRender or use the FormatString property on the column:
    Context.ResourceManager.AddCurrentCultureGlobalizationResource()
    gkumik9
    @gkumik9

    Thank you for your answer. It works. But I have the same problem in popup. I have a modal with DateTime field. When I save, my spinner spins and the popup does not close.
    If I delete a section from datetime, the popup works fine.

    public bool OpenDialog(DefProcessComponents_DB model)
    {
    //loading data
    Visible = true;
    return Visible;
    }
    public bool CloseDialog()
    {
    Visible = false;
    return Visible;
    }
    public async Task Save()
    {
    //saving data
    CloseDialog();
    }

    <div>
    <div><label for="Date">{{resource: res.Date }}</label></div>
    <bs:DateTimePicker SelectedDate="{value: model.Date }" Validator.Value="{value: model.Date }" Mode="DateTime" Validator.InvalidCssClass="invalid" autocomplete="off" />
    </div>

    Lubos
    @tatran_twitter
    Is there a way or control that could be used to update its data every, say 10 seconds? Like staticCommand call to a webservice or something similar?
    Jan Berger
    @kamm85

    @tatran_twitter You can call methods like:
    dotvvm.postBack(), dotvvm.staticCommandPostback()

    Simple way to get js code is render <dot:button> with command/staticCommand in Click event, run project and copy js code (method call with params) to your special processing script :-)

    Next step is on your side.. e.g. window.setInterval( function() { dotvvm.postBack(xxx); }, 10000);

    Tomáš Herceg
    @tomasherceg
    @kamm85 I recommend keeping the button in the page, hiding it using CSS (style="display: none") and calling document.getElementById("refreshButton").click(); The syntax of dotvvm.postBack can change when you modify the viewmodel or when we publish a new version of DotVVM.
    @gkumik9 Is there the same error message in the dev console?
    Lubos
    @tatran_twitter
    Mam trosku problem with session cookies. 2 different applications running on IIS do knock each other out... What is the best approach?
    image.png
    Tomáš Herceg
    @tomasherceg
    @tatran_twitter Both apps are running on the same domain, so they are sharing the SID cookie. If it is the case only on your dev machine, you can make each app run on a different port (the port number is added in the cookie name so it won't be shared). If the domain is the same in production and other environments too, you'll need to override the CSRF protector to set the cookie path. Or if it's possible to have a separate subdomain for each app, that would solve the problem too.
    Stanislav Lukeš
    @exyi
    @tatran_twitter That's a good point, I thought two applications on one domain will work since they will share the IDataProtectionProvider. Apparently it does not have to be the case when they are not in the same Asp.Net Core instance :/
    Anyway, you can also try to enable "lazy csrf tokens" experimental feature (assuming you are on a new enough version). The applications will still override the cookies to each other, but they will do it transparently to the user.
    config.ExperimentalFeatures.LazyCsrfToken.EnableForAllRoutes()
    Correction: you don't even have to enable the lazy loading to enable the failure handler, just upgrade to 2.4 should do.
    koenmichielsen
    @koenmichielsen
    Hi, I came across DotVVM searching for a migration of Webforms to .NET Core. I have developed a CMS system (made with Webforms), which I am using already for many years now. DotVVM seems a nice solution for me to migrate my CMS. Most of the functionality of the CMS consists of generating form fields (Textboxes, Text editors, a.s.o) at runtime. Is this also possible with DotVVM ? And if so, is there some sample code available to achieve this ? Thanks in advance
    Tomáš Herceg
    @tomasherceg
    @koenmichielsen The process of creating controls dynamically is similar to Web Forms - you can mark a control with ID attribute, find it in the viewmodel and add controls in its Children collection. There is also API to build data-binding expressions, so it's definitely possible.
    We even have the DotVVM Dynamic Data library which can generate forms and grid columns using Data Annotation Attributes. https://github.com/riganti/dotvvm-dynamic-data
    koenmichielsen
    @koenmichielsen
    Thank you Tomas, very interesting for me, I will take a closer look.
    gkumik9
    @gkumik9

    I use this method to download files:

    public async Task PrintSpecificationAsync(Model_DB mode)
    {
    string host = Context.HttpContext.Request.Url.AbsoluteUri.Replace(Context.HttpContext.Request.Url.AbsolutePath, "");
    var bytes = await TheMagicHtml2Pdf.Go(host + "/PrintSpecification/" + mode.ID, string.Empty);
    Context.ReturnFile(bytes, mode.NAME + ".pdf", "application/pdf");
    }

    after generating the file a browser window appears (save / open file), but the code block (dotvvm.events.afterPostback.subscribe) is not executed

    dotvvm.events.afterPostback.subscribe(function () {
    sending = false;
    setTimeout(checkVariable, 200);
    });

    function checkVariable() {
    if (sending) {
    $('#loader-wrapper').show();
    } else {
    $('#loader-wrapper').hide();
    }
    }

    My loader is still active, even after closing the download window

    Tomáš Herceg
    @tomasherceg
    @gkumik9 The ReturnFile performs a redirect, thus the afterPostback is not called. Is it possible to use the UpdateProgress control to show the loader-wrapper element - it should work on this occasion.
    gkumik9
    @gkumik9
    Thank you Tomas, I did it using the link (target _blank)
    AHMET URUN
    @ahmeturun
    Hi, as most poeple before me I came across DotVVM while searcing for a way to migrate from web forms to .net core. I see that it has a very similar structure to web forms and it's great because it supports .net core, but I couldn't quite find it anywhere if there is any way to convert a custom control to dotvvm control? I see that there is this part in the documentation "https://www.dotvvm.com/docs/tutorials/control-development-markup-only-controls/2.0" but I'm not sure if this is the exact match of ScriptControl of web forms, can anyone provide some information on this, much appreciated.
    Stanislav Lukeš
    @exyi

    Hi @ahmeturun, I don't really know what ScriptControl does in web forms, if my quick google search suggests correctly it is adding Javascript to the page? In DotVVM we have a mechanism for generic resource management - see https://www.dotvvm.com/docs/tutorials/basics-javascript-and-css/2.0, https://www.dotvvm.com/docs/tutorials/basics-using-resources/2.0

    If that's not not what you are looking for, could you please describe what are you actually trying to achieve. DotVVM is not WebForms reimplementation for .NET Core, only the target audience (BLOBAs) and syntax are kindof similar.

    AHMET URUN
    @ahmeturun
    DotVVM is not WebForms reimplementation for .NET Core well I saw that it is not. and to be honest even I'm not sure what is this ScriptControl is(we have some legacy code that was there before), but what it does as I understand is that you create costomized components to use with webforms, for example webforms already offers a GridView control out of the box, by implementing ScriptControl you create your own control and use it just like any other webform component
    what I'm trying(hoping) to do is to be able to use this controls without so much change in the business layer. And it seems that is not going to happen
    to be on the same page this is the thing I'm talking about => https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.scriptcontrol?view=netframework-4.8
    Stanislav Lukeš
    @exyi

    I see, that might not be very easy... depends on what does the control do.

    Anyway, ScriptControl seems to be just a thin wrapper of WebControl - https://referencesource.microsoft.com/#System.Web.Extensions/UI/ScriptControl.cs,58b733a27b359dd4. You can probably just inherit from DotvvmControl and see what does not compile next.

    Or you can inherit from HtmlGenericControl, if you want to create a html tag.
    However, in doing something from the controls is not considered a good practise in DotVVM, we try to put as much as possible into the view model and use the controls only for "presentation". You can do it to migrate some code, but please don't crate new controls like this :)
    AHMET URUN
    @ahmeturun
    :D right I see, maybe it is time to make some serious refactoring and even rewriting..
    thanks for the resources, I'll check what can be carried and what needs to be refactored then.