This is a migrated thread and some comments may be shown as answers.

BUTTON CLICK LOAD CONTROLLER IN JAVA SCRIPT

7 Answers 334 Views
Button (Mobile)
This is a migrated thread and some comments may be shown as answers.
E
Top achievements
Rank 1
E asked on 01 Sep 2013, 05:27 PM
HELLO I HAVE APPLICATION MOBILE IN RAZOR ASP.NET

I HAVE HOMECONTROLLER WITH THIS ACTION

PUBLIC ACTIONRESULT HELLO()
{
RETURN VIEW()
}

I WANT TO CALL IT  IN BUTTON CLICK
HOW CAN I DO????????
<script>
FUNCTIONCLICK (e)
{
     //CALL home, hello???????????????????????????????????????????????
}
</script>

THANK YOU

7 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 02 Sep 2013, 10:07 AM
Hi,

You can make asynchronous requests to the server using the jQuery ajax method. For example:
<script>
FUNCTIONCLICK (e)
{
   $.ajax({
      url: 'MyController/HELLO',
      type: 'POST'
    });
}
</script>

 
Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
E
Top achievements
Rank 1
answered on 03 Sep 2013, 12:38 AM
yes I try to do it in my login view:

@{    
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@(Html.Kendo().MobileView()
        .Name("ViewLogin")
        .Layout("layout")        
        .Content(
            @<text>
               
                @(Html.Kendo().MobileListView()
                   .Style("inset")
                    .Items(root =>
                    {
                        root.Add().Text("<label for=\"username\">Usuario:</label> <input type=\"text\" id=\"text\" placeholder=\"Usuario\" required />");
                        root.Add().Text("<label for=\"username\">Contraseña:</label> <input type=\"password\" id=\"password\" placeholder=\"Contraseña\" required  />");
                    })
                  )  
               
                @(Html.Kendo().MobileButton()
                   .Name("login")
                   .Text("Login")
                   .HtmlAttributes(new { @class = "button", ChartTextAlignment.Center })
                   .Events(events => events.Click("onClick"))
                   ) 
            </text>)
                    
)
 
@(Html.Kendo().MobileLayout() 
       .Name("layout")
       .Header(obj =>
           Html.Kendo().MobileNavBar()
            .Content(navbar =>
                @<text>
                @navbar.ViewTitle("Iniciar Sesión")
                </text>)            
        )
)
)

<script>

    function onClick(e) {
     var dataPost = { "user": $("#text").val() };
                $.ajax({
                    url: "@Url.Action("Reporte", "Report")",
                    type: 'POST',
                    data: dataPost,
                    success: function (datis) {
                    }
                });
    }
</script>

but my controller action view Report doesn´t load
this is my Report.cshtml

@model KendoUIMobile.Models.FiltroS

@{    
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@(Html.Kendo().MobileView()
       .Name("drawer-home")
       .Layout("drawer-layout")
       .Title("Inbox")
       .Content(obj =>       
           Html.Kendo().MobileListView()
                .HtmlAttributes(new { @class = "inboxList" })
                .Items(items =>
                {
                    items.Add().Content(
                    @<text>
                        <h3 class="time">07:56</h3><h3>John Doe</h3>
                        <h2>Monday meeting</h2>
                        <p>Hi Tom, Since Monday I'll be out of office, I'm rescheduling the meeting for Tuesday.</p>
                    </text>);

                })
        )
)

@(Html.Kendo().MobileLayout()
       .Name("drawer-layout")
       .Header(obj =>        
            Html.Kendo().MobileNavBar()
                .Content(navbar =>
                    @<text>
                    @(Html.Kendo().MobileButton()
                            .Align(MobileButtonAlign.Left)
                            .Icon("settings")
                            .Rel(MobileButtonRel.Drawer)
                            .Url("#my-drawer")
                    )

                    @navbar.ViewTitle("")

                    @(Html.Kendo().MobileButton()
                            .Align(MobileButtonAlign.Right)
                            .Text("Index")
                            .HtmlAttributes(new { @class = "nav-button" })
                            .Url(Url.RouteUrl(new { controller = "suite" }))
                    )

                </text>)
        )
)


@(Html.Kendo().MobileDrawer()
        .Name("my-drawer")
        .Views("drawer-home")
        .Content(obj =>
            Html.Kendo().MobileListView().Type("group")
                .Items(root => {
                    root.Add().Text("Reporte").Items(items =>
                    {
                       items.Add().Content(
                            @<text>
                                <label>Unidad</label> 
                                <select name="select-unidad" id="select-unidad">
                                    @foreach(var ur in Model._Unidades)
                                    {
                                        <option value="@ur.Id">@ur.Ur</option>          
                                    }
                                </select>
                            </text>);
                            items.Add().Content(
                            @<text>
                            <label>Programa</label> 
                                <select name="select-programa" id="select-programa">
                                <option value="0">TODOS</option>
                                </select>
                            </text>);
                            items.Add().Content(
                            @<text>
                            <label>Año</label>
                                <select name="Year" id="Year">
                                @foreach(var an in Model._Year)
                                {
                                <option value="@an._id">@an._anio</option>
                                }
                                </select>
                            </text>                           
                            );
                            items.Add().Content(
                            @<text>
                            <label>Mes</label>
                                <select name="select-mes" id="select-mes">
                                    <option value="1">Enero</option>
                                    <option value="2">Febrero</option>
                                    <option value="3">Marzo</option>
                                    <option value="4">Abril</option>
                                    <option value="5">Mayo</option>
                                    <option value="6">Junio</option>
                                    <option value="7">Julio</option>
                                    <option value="8">Agosto</option>
                                    <option value="9">Septiembre</option>
                                    <option value="10">Octubre</option>
                                    <option value="11">Noviembre</option>
                                    <option value="12">Diciembre</option>
                                </select>
                            </text>                           
                            );
                        items.Add().Content(
                                @<text> 
                                     @(Html.Kendo().MobileButton()
                                       .Name("login")
                                       .Text("Login")
                                       .HtmlAttributes(new { @class = "button", ChartTextAlignment.Center })
                                       .Events(events => events.Click("onClick"))
                                     )
                                </text>);
                            
                            
                    });

                    root.Add().Text("Account").Items(items =>
                    {
                        items.Add().Icon("off").Text("Log Out");                   
                    });
                })
        )
)

i try to window.location.href but doesn´t work also

Can you help me please..

Thank you


0
Alexander Popov
Telerik team
answered on 03 Sep 2013, 12:31 PM
Hello,

I examined the code snippets, but could not find the reason why the controller method is not called. Could you please provide runnable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
E
Top achievements
Rank 1
answered on 03 Sep 2013, 02:16 PM
yeah! Thank you
i dont understand too....
this is my complete code...


0
Alexander Popov
Telerik team
answered on 05 Sep 2013, 01:26 PM
Hi,

I reviewed the project and managed to reproduce the issue, however it seems that it's related to the database connection. When I click on the login button GetUsuario method is trying to connect to the database but fails and this is why you never reach the Reporte ActionResult method. I tried to use static data instead of accessing the database and it worked. Here is a screencast demonstrating it.

 

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
E
Top achievements
Rank 1
answered on 06 Sep 2013, 05:22 PM
Thank you for your answer It´s work great =)
bay the way i have other problem
when i load the page in horizontal form by first time doesn´t expand complete in IPAD 
why????
Can you help me please thank you very much...
0
E
Top achievements
Rank 1
answered on 06 Sep 2013, 10:10 PM
I resolved it =) thank you 
Tags
Button (Mobile)
Asked by
E
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
E
Top achievements
Rank 1
Share this question
or