Copied to clipboard

Flag this post as spam?

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


  • pushpendu 23 posts 113 karma points
    Jan 06, 2015 @ 09:33
    pushpendu
    0

    problem while getting value from .Net UserCantrol in my Umbraco frontend

    Hi guys,

    I am trying to Add Asp.net Web user control in umbraco ,though I have succeed little but not fully. I have created simple UserCantrol where user can enter his name, Hit submit and his name get displayed in the literal below.

    I was successful in displaying the Textbox and the button in the frontend using Razor, but the problem is when user enter his name and hit submit. I don't get named displayed in the literal below.

    Here my ascx code:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="powered.ascx.cs" Inherits="keylime.powered" %>
    <p>
    Enter Your Names:</p>
    <p>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />
    </p>
    <asp:Literal ID="Literal1" runat="server"></asp:Literal>

    Here my ascx.cs code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace keylime
    {
    public partial class powered : System.Web.UI.UserControl
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
    Literal1.Text = "Value" + TextBox1.Text;
    }
    }
    }

    Here is my template umbraco template page code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "master.cshtml";
    }
        <form runat="server">
        @Umbraco.RenderMacro("new")
        </form>

    I am using Umbraco Cms 7.2.1 and .net Framework 4.2.

    Thanks

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jan 06, 2015 @ 10:37
    Ismail Mayat
    1

    You are trying to mix webforms with mvc you cannot do that. If you look in your umbracoSettings.config you will see line 

        <!-- To switch the default rendering engine to MVC, change this value from WebForms to Mvc -->

        <defaultRenderingEngine>Mvc</defaultRenderingEngine>

    by default in umbraco 7 its mvc. If you change to webforms then it should work although you will need to recreate your templates becuase as it stands they are mvc. I would ditch the webforms stuff altogether and do it with mvc.

    Regards


    Ismail

     

Please Sign in or register to post replies

Write your reply to:

Draft