Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Víctor Manuel 10 posts 31 karma points
    Sep 15, 2010 @ 10:54
    Víctor Manuel
    0

    Problems creating a form from a user control

    Hi all,

    First of all sorry for my english,

    I'm new to umbraco and I have to migrate an existing web to it.

    The old web is builded using .aspx pages which use javascript extensively and from it are called c# funtions, so forms have the atribute runat=server.

    To migrate, I'm using user controls, I declare my forms tags (i.e. <form id="formulario" method="post" runat="server">) but when I run the page this declaration is always changed to <form method="post" action="my_page" id="aspnetForm">

    Could someone help me?

    thanks,

         Víctor Manuel.


  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 11:34
    Matt Brailsford
    0

    Hi Victor,

    I'm not sure what you are saying the problem is?

    What you have described, would seem to be the expected behavour. When a form tag with runat="server" is rendered as HTML, it will be rendered as a standard form tag like you've stated.

    Can you explain your problem a little further?

    Many thanks

    Matt

  • Jon 17 posts 40 karma points
    Sep 15, 2010 @ 11:41
    Jon
    0

    I think what Victor's saying (and I say this because I'm seeing the same on my install) is that it's changing the id of the form specified in the template. So, in my master template I declare the form as follows:

    <form id="masterForm" runat="server">

    Which then renders as:

    <form method="post" action="my_page" id="aspnetForm">

     

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 11:52
    Matt Brailsford
    0

    Hi Jon / Victor

    Ahhhh, I see.

    Well it looks like this is an problem with asp.net when using a form tag in a master page.

    Take a look at this forum post on asp.net for more info

    http://forums.asp.net/p/883974/929349.aspx

    Matt

  • Jon 17 posts 40 karma points
    Sep 15, 2010 @ 11:57
    Jon
    0

    Ahh that's interesting. I'd just assumed it was Umbraco doing it rather than .net. Fortunately it's not really a problem in my site and I can work around it, but it's certainly something to bear in mind.

    Thanks for the help Matt!

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 12:00
    Matt Brailsford
    0

    No Problem,

    I did check, but as far as I can tell, the only place Umbraco touches the form tag is the action attribute because of the URL rewriting. Everything else it left to the default .NET implementation.

    Matt

  • Víctor Manuel 10 posts 31 karma points
    Sep 15, 2010 @ 12:13
    Víctor Manuel
    0

    Matt, thanks for your link, but my real problem it isn't the id changed, it is that I need to access from javascript to the functions defined in .ascx.cs files, but if the atribute "runat=server" is deleted when HTML is rendering I couldn't do that.

    perhaps if I translate the javascript functions to c# funtions I'll solve my problem...

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 12:27
    Matt Brailsford
    0

    Hi Victor,

    I still don't see how the runat="server" attribute would affect this.

    Can you post some example code for your poblem area? ie javascript calls that aren't working?

    Many thanks

    Matt

  • Víctor Manuel 10 posts 31 karma points
    Sep 15, 2010 @ 12:46
    Víctor Manuel
    0

    Ok, here is some code of my web...

     

    .ascx

    <%@ Control Language="C#" AutoEventWireup="true" Codebehind="ModoMapa.ascx.cs" Inherits="RideSharing.TiempoReal.ModoMapa" %>
    <script type="text/javascript" src="something.js"></script>
    .............................
    <form id="formulario" method="post" runat="server">
    ......................
    .....................
    <table id="TABLE1">
    <tr>
    <td style="width: 370px">
    <strong><span style="font-size: 9pt; font-family: Verdana">Escoja el tipo de origen:</span></strong>
    <select id="ListaOrigenesMP" name="ListaOrigenesMP" onchange="JAVASCRIPT()">
    <option selected="selected" value="0">Casa</option>
    <option value="1">Trabajo</option>
    <option value="2">Existente</option>
    <option value="3">Otros</option>
    </select>
    </td>
    </tr>
    </table>
    </form>

    something.js

    function mostrar(elemento)
    {
    var elemento = document.getElementById(elemento);
        var response = RideSharing.conductores.AnadirRutas.CargarCasaUsuarioOrigen(); (fail in this line, "Ridesharing not found")
    CasaOrigen.innerHTML = response.value;
        elemento.style.display = '';
    }

    Thanks,

    Victor.

    
    
                
  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 12:57
    Matt Brailsford
    0

    Hi Victor,

    And how / where is

    RideSharing.conductores.AnadirRutas.CargarCasaUsuarioOrigen

    Defined?

    Matt

  • Víctor Manuel 10 posts 31 karma points
    Sep 15, 2010 @ 13:05
    Víctor Manuel
    0

    oh, sorry, I forget to include ascx.cs file

    using...

    namespace RideSharing.Conductores
    {
    public partial class ModoMapa : System.Web.UI.UserControl
    {
    some code..........

    protected void Page_Load(object sender, System.EventArgs e)
    {
    Utility.RegisterTypeForAjax(typeof(ModoMapa));
    Utility.RegisterTypeForAjax(typeof(RideSharing.Comun.Lugares));

       some code....
            }
           
            [AjaxMethod(HttpSessionStateRequirement.ReadWrite)]
    public string CargarCasaUsuarioOrigen()
    {
    try
    {
    some code.....

    }

    catch (Exception ex)
    {
    some code....
    }
    }
        }
    }
       


     

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 14:28
    Matt Brailsford
    0

    Ahhh, ok.

    I don't really have much experience using AjaxMethods or WebMethods. I know others have had issues, but not sure what there solutions were.

    I tend to just use jQuery for my akax calls, and either use /base (http://umbraco.org/documentation/books/introduction-to-base) or just umbraco alternative templates to return the HTML.

    Sorry I can't be of much help for your current method, but if you need more details on the other methods, please let me know.

    Matt

  • Víctor Manuel 10 posts 31 karma points
    Sep 15, 2010 @ 16:26
    Víctor Manuel
    0

    Matt, /base solution has made me a good impresion. I've achieve to call a function in mi ascx.cs file from javascript, but making this:

    window.location="http://localhost/base/ModoMapa/CargarCasaUsuarioOrigen.aspx"

    CargarCasaUsuarioOrigen is a function that returns a String, since window.location loads a page with this String, Is there any way to obtain this string whitout making a window.location?

    I don't know if I have explained well...

    Victor.


     

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 15, 2010 @ 16:31
    Matt Brailsford
    0

    Hi Victor,

    I'd look into using one of the jQuery ajax methods to make the request and load the result (http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/).

    If you just want to load a string, and handle it once loaded, look into jQuery.get

    Cheers

    Matt

  • Víctor Manuel 10 posts 31 karma points
    Sep 16, 2010 @ 10:53
    Víctor Manuel
    1

    Hi all,

    I just solve my proble. All were alright except I hadn't configured my web.confg to can use ajax in my web.
    This two lines were missing:

    <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
    <add verb="*" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>

    Thank you very much.

    Víctor.

  • Matt Brailsford 4124 posts 22220 karma points MVP 9x c-trib
    Sep 16, 2010 @ 10:55
    Matt Brailsford
    0

    Hi Victor.

    Excellent work figuring this one out, am sure it will help others in future, and glad you got your project working.

    Matt

  • acasado 3 posts 23 karma points
    Nov 09, 2011 @ 13:59
    acasado
    0

    Hi to all,

    Sorry for my english. I have a very similar issue than Victor Manuel. I made a web control using ajax and the tests in local .net debug server were all ok. But when I upload this user control to umbraco i get the same error than Victor Manuel. I have tried to fix the error with the indications above, but the error continue. The server can't locate /ajax/<HandlerName>.ashx.

    I am using UMBRACO 4.7.0 in a IIS 7 server. To upload the user control I copied the .aspx to /usercontrol folder and i copied the ajax.dll and <userControlName>.dll to /bin folder.

    At finish, i edited the web.config file and i added <add verb="POST,GET" path="/ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />

    Can anybody help me?

    Thanks

  • Víctor Manuel 10 posts 31 karma points
    Nov 11, 2011 @ 09:04
    Víctor Manuel
    0

    Hi acasado!,

    I remember that I had that problem when I uploaded the web to the production serverm, Windows Server 2008. In my case, It was problem of the IIS configuration.

    My solution was change the application pool to the "Classic .NET AppPool".

    Best Regards. 

     

     

     

  • acasado 3 posts 23 karma points
    Nov 14, 2011 @ 16:10
    acasado
    0

    Hola Victor (he visto que eres Pucelano)!!!

    Thanks for your response. It was very useful for me. The problem was solved changing the AppPool to the Clasic .net.

     

Please Sign in or register to post replies

Write your reply to:

Draft