[CLOSED] Javascript and MVC application

Page 1 of 3 123 LastLast
  1. #1

    [CLOSED] Javascript and MVC application



    Hello,


    in an MVC application I have the following View (Test.aspx):


    
     <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    
     <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
     <html xmlns="http://www.w3.org/1999/xhtml">
     <head id="Head1" runat="server">
      <title>Test</title>
     </head>
     <body>
      <form id="Form1" runat="server">
       <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    
       <ext:Window ID="Window1" 
        runat="server"
        Title="Resize Me"
        Icon="ArrowOut"
        Width="500"
        Height="300"
        MinWidth="300"
        MinHeight="200"
        Plain="true" 
        Padding="5"
        ButtonAlign="Center"
        LabelWidth="55"
        Layout="Form">
        <Items>
         <ext:TextField ID="TextField1" runat="server" FieldLabel="Send to" AnchorHorizontal="100%" />
         <ext:TextField ID="TextField2" runat="server" FieldLabel="Subject" AnchorHorizontal="100%" />
         <ext:TextArea ID="TextArea1" runat="server" HideLabel="true" AnchorHorizontal="100%" AnchorVertical="-53" />
        </Items>
        
        <Buttons>
         <ext:Button ID="Button1" runat="server" Text="Save" Icon="Disk" />
         <ext:Button ID="Button2" runat="server" Text="Cancel" Icon="Decline" />
        </Buttons>
       </ext:Window>
      </form>
     </body>
     </html>
    and the related controller's method:


            public ActionResult Test()
            {
                return View();
            }

    I'd like to invoke the Test() method from client code. I tried with this code:


    
     var myTest = function () {
      Ext.Ajax.request({
       url: '/General/Test'
      });

    but when I invoke myTest function, nothing happens, even if the Test method is correctly invoked.
    Is this the right method to accomplish this?
  2. #2

    RE: [CLOSED] Javascript and MVC application

    Hi,

    More information is required. Are you trying to redirect to another page/view? If no, what should happen if the view is returned? are you injecting this html into another document?


    Your Ext.Ajax.request code appears to be fine and makes the ajax call properly.


    I'm just not sure what should be happening here.




    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Javascript and MVC application



    Hi,

    I would simply redirect to another page (view), passing it same parameters.

    Bue,
    Stefano
  4. #4

    RE: [CLOSED] Javascript and MVC application

    Hi,

    If you're redirecting to another url, you can set the window.location.href property in client-side JavaScript.


    Example


    window.location.href="http://www.google.com/";

    Parameters could also be passed in the QueryString.


    Hope this helps.


    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] Javascript and MVC application

    Hi Geoffrey,

    this is not a good solution for me. I can't pass parameters in the QueryString (I have to use POST method and the view must be opened modally).
    Is there an alternate way to accomplish this using the Ext.net framework and respecting the MVC infrastructure?

    Bye,
    Stefano
  6. #6

    RE: [CLOSED] Javascript and MVC application

    Thanks for the update.

    The problem from my perspective is I don't understand exactly what you are trying to implement. Can you break down the description of your scenario into greater detail... more description, or maybe screen capture/mockup?


    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] Javascript and MVC application



    Hi Geoffrey,

    I try to explain what I want to get.

    - I'm in a page with a GridPanel in it
    - I select a row in the grid
    - I click a button on the toolbar. Here, client is invoked to open modally a view.
    - Some of the fields of the selected row must to be passed to the view as parameters, but i can't pass them in the QueryString.

    Bye,
    Stefano
  8. #8

    RE: [CLOSED] Javascript and MVC application

    Hi,

    Can you provide more details about
    Here,
    client is invoked to open modally a view.
    How do you open a view? To the same page or to another container as iframe? Or something else?
  9. #9

    RE: [CLOSED] Javascript and MVC application



    Hi,

    I have to open a view like this:

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    
            <ext:Window ID="Window1" 
                runat="server"
                Title="Test"
                Width="500"
                Height="300"
                Layout="Form">
                <Items>
                     .....
                     .....
                </Items>
                
                <Buttons>
                    <ext:Button ID="Button1" runat="server" Text="Save" Icon="Disk" />
                    <ext:Button ID="Button2" runat="server" Text="Cancel" Icon="Decline" />
                </Buttons>
            </ext:Window>
        </form>
    </body>
    </html>
    Bye,
    Stefano
  10. #10

    RE: [CLOSED] Javascript and MVC application

    I have to open a view like this:
    Hi Stefano,


    Unfortunately we're still lost. Your last code sample doesn't really tell us much. Are you loading that page into the body of another Panel?


    What does "Here, client is invoked to open modally a view." mean?


    You'll need to provide more details.


    Geoffrey McGill
    Founder
Page 1 of 3 123 LastLast

Similar Threads

  1. [CLOSED] Login MVC application
    By romeu in forum 2.x Legacy Premium Help
    Replies: 10
    Last Post: May 14, 2013, 12:39 PM
  2. [CLOSED] Calendar with MVC application
    By romeu in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 08, 2012, 5:47 PM
  3. [CLOSED] Login MVC application
    By romeu in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Mar 05, 2012, 7:22 PM
  4. Replies: 5
    Last Post: Jul 25, 2011, 6:14 PM
  5. [CLOSED] Application Performance
    By Hari_CSC in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 14, 2010, 6:11 PM

Posting Permissions