Create new JFunction in C# is ok but not in VB

  1. #1

    Create new JFunction in C# is ok but not in VB

    I'm a newbie in VB and ext. Now i have a project with asp.net with VB
    I wanna create some example with VB (on ext.net we only have demo with C#) and i have a trouble:
    The javascript code is to display a notification as the demo of ext.net. We can see more about this demo on: https://examples1.ext.net/#/MessageBox/Basic/Overview/

    However i can't reproduce this demo in VB.

    I can call my Javascript code in C# (it's work).
    <script runat="server">
             protected void Button2_DirectClick(object sender, Ext.Net.DirectEventArgs e)
             {
                 var a = new JFunction { Fn = "showResult" };
                 (new MessageBox()).Confirm("Confirm", "Are you sure you want to do that?", new JFunction { Fn = "showResult" }).Show();
             }
                
        </script>
    The VB code (that doesn't work)

    <script runat="server">
            Protected Sub Button1_Click(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs) Handles Button1.DirectClick
                Dim msb As MessageBox = New MessageBox()
                       msb.Confirm("Confirm", "Are you sure you want to do that?", New JFunction("showResult")).Show()
                       
            End Sub
        </script>
    The Javascript code for C# and VB are the same:

    <script type="text/javascript">
                var showResult = function (btn) {
                    Ext.Msg.notify("Button Click", "You clicked the " + btn + " button");
                };
    
                var showResultText = function (btn, text) {
                    Ext.Msg.notify("Button Click", "You clicked the " + btn + 'button and entered the text "' + text + '".');
                };
    </script>
    How can i pass this trouble ?
  2. #2
    khoa_chung_89

    1.- you change
    <%@ Page Language="C#" ... %>
    to
    <%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="DriveBusiness_Tracking._Default" %>
    2.- maybe need save and close VStudio

    3.- by the way, the code behind (no javascript) for the confirm dialog is (c#)
    private void ShowMsg()
    {
        MessageBoxConfig config = new MessageBoxConfig();
        config.Title = "QUESTION";
        config.Message = "CONFIRM?";
        config.Closable = false;
        config.Icon = MessageBox.Icon.QUESTION;
        config.Buttons = MessageBox.Button.YESNO;
        config.MessageBoxButtonsConfig= new MessageBoxButtonsConfig
        {
            Yes = new MessageBoxButtonConfig { Handler = "Ext.net.DirectMethods.ClickedYES()", Text = "YES" },
            No = new MessageBoxButtonConfig { Handler = "Ext.net.DirectMethods.ClickedNO()", Text = "NO" }
        };
        X.Msg.Show(config);
    }
    4.- A good page to convert C# to VB is http://www.developerfusion.com/tools.../csharp-to-vb/
  3. #3
    Yeap! Thank you :)
    By your link, I found that in VB, name of field or property being initialized must start with '.' :)
    sorry if it's too simple for you, i'm newbie in VB :)

Similar Threads

  1. Ext.Create in Ext v1
    By peter.campbell in forum 1.x Help
    Replies: 0
    Last Post: May 15, 2012, 9:44 AM
  2. [CLOSED] X.Msg.Show with JFunction
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 20, 2011, 10:18 AM
  3. how to create new tab from exisisting tab
    By harshad.jadhav in forum 1.x Help
    Replies: 3
    Last Post: Dec 03, 2010, 1:54 PM
  4. JFunction for TreeGrid from codebehind
    By rajputamit in forum 1.x Help
    Replies: 2
    Last Post: Nov 01, 2010, 7:38 AM
  5. [CLOSED] How would I create this?
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Sep 29, 2010, 2:36 PM

Tags for this Thread

Posting Permissions