Copied to clipboard

Flag this post as spam?

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


  • Dipa 88 posts 370 karma points
    May 24, 2016 @ 08:48
    Dipa
    0

    User control : add info to content node

    Hello, I am using .Net control first time in umbraco. In that user control, I have one form which will add that all information under the one of node under 'Content' node.

    Now my query is, how much part I have to complete in user control before adding to umbraco project? Or should add only blank user control then set property after adding to umbraco project?

    Help me for how to prepare this kind of user control?

    Thanks, Dipa

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 24, 2016 @ 16:53
    Alex Skrypnyk
    0

    Hi Dipa,

    Can you show your code?

  • Dipa 88 posts 370 karma points
    May 25, 2016 @ 04:22
    Dipa
    0

    Hi Alex, In code till now I have written only code which is getting values. till that working fine and till now I haven't add .ascx file to my Umbraco project.

    My query is, 1) Should I add code which will add information to node under 'Content' node? Or after adding that simple coded .acsx file to project, I should write code which will add info to content node?

    2) I have tried with simple user control in demo project, but when I copy only .ascx file to 'usercontrol' folder, Its copying .ascx.cs file also and it is pointing to that project from which I have copied that control. For that where am I doing mistake?

    Guide me for these two queries.

    Thanks, Dipa

  • Dipa 88 posts 370 karma points
    May 25, 2016 @ 10:36
    Dipa
    0

    Hi Alex,

    Here is the code of my user control.

    1) .ascx.cs file

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace RequestForm
    {
        public partial class RequestForm : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                    Label5.Text = "Please fill your information";
                else
                    Label5.Text = "Info is filled.";
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                Label5.Text = TextBox1.Text + ", " + TextBox2.Text + ", " + TextBox3.Text + ", " + TextBox4.Text;
            }
    
            protected void Button2_Click(object sender, EventArgs e)
            {
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox4.Text = "";
            }
        }
    }
    

    2) .ascx file

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RequestForm.ascx.cs" Inherits="RequestForm.RequestForm" %>
    <asp:Panel ID="Panel1" runat="server">
        <br />
        <asp:Label ID="Label1" runat="server" Text="Title"></asp:Label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Description"></asp:Label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Label ID="Label3" runat="server" Text="User Name"></asp:Label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Label ID="Label4" runat="server" Text="Company Name"></asp:Label>
        &nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Request" />
        &nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button2" runat="server" Text="Clear" OnClick="Button2_Click"/>
        <br />
        <br />
        <asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
    </asp:Panel>
    

    I have added dll and .ascx file to my umbraco project. Its showing form proper. But now issue is on click of 'Send Request' button it is not displaying expected output. And URL become like this :

    http://localhost:22222/new-request?RequestForm_1%24TextBox1=&RequestForm_1%24TextBox2=&RequestForm_1%24TextBox3=&RequestForm_1%24TextBox4=&RequestForm_1%24Button1=Send+Request
    

    Not getting what is the issue. Please help me.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 25, 2016 @ 10:54
    Alex Skrypnyk
    0

    Hi Dipa,

    What Umbraco version are you using?

    Looks like you try to use webForms usercontrol in MVC project.

    You have to decide which render engine to use.

    If you want to use .net usercontrol you have to look at Master.master, there should be

    after tag.

    Changing Rendering Engine

    You can change the engine on umbracoSettings.config. It is located on /Config/ folder

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

    Cheers,

    Alex

  • Dipa 88 posts 370 karma points
    May 25, 2016 @ 11:03
    Dipa
    0

    Hi Alex,

    Here is detail about versions :

    Umbraco version 7.4.3 assembly: 1.0.5948.18141
    

    And in defaultRenderingEngine I have mentioned WebForms keyword. Though it is not working.

    Any thing else am I missing?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 25, 2016 @ 11:35
    Alex Skrypnyk
    1

    Check, please,

    tag in the Master.master

  • Dipa 88 posts 370 karma points
    May 25, 2016 @ 11:40
    Dipa
    0

    Hi, there is no anything like 'Master.master' in entire solution.

    Can you please elaborate it?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 25, 2016 @ 11:45
    Alex Skrypnyk
    0

    Dipa, I meant Master of your page. What template are you using? Try to check "masterpages" folder.

    /Alex

  • Dipa 88 posts 370 karma points
    May 25, 2016 @ 11:55
    Dipa
    0

    In masterpages folder, there are three files

    1) default.Master 2) umbracoDialog.Master 3) umbracoPage.Master

    If I am interpreting anything wrong, please guide me.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 25, 2016 @ 12:07
    Alex Skrypnyk
    0

    Can you define which of these templetes are using on your page ?

    You can look at Umbraco node, Properties tab.

    Screen example:

    http://screencast.com/t/RtRqJWQm0

  • Dipa 88 posts 370 karma points
    May 25, 2016 @ 12:18
    Dipa
    0

    As master page I have created one own master page, which is actually a .cshtml file.

    and here master page is :

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    <!doctype html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="/favicon.ico?ver=2" type="/image/x-icon" rel="shortcut icon">
        <title>Managed Services Community</title>
        <link rel="stylesheet" type="text/css" href="~/css/Style.css">
        <script src="~/scripts/jquery-1.10.2.js"></script>
    </head>
    <body>
        <div class="header">
            <div class="header-top">
                <div class="logo">
                </div>
            </div>
        </div>
        <div class="ContentAreaBox">
            @RenderBody()
        </div>
    </body>
    </html>
    
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 25, 2016 @ 12:32
    Alex Skrypnyk
    100

    Dipa, it what I said on top - this is not WebForms template - this is Razor, you need to use WebForms template with usercontrols.

    Change your template please.

  • Dipa 88 posts 370 karma points
    May 26, 2016 @ 09:58
    Dipa
    0

    Okey, Got it.

    Thanx Alex

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 26, 2016 @ 10:04
    Alex Skrypnyk
    0

    You are welcome, write if something.

    Cheers

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jun 24, 2016 @ 18:01
    Alex Skrypnyk
    0

    Dipa, can you mark the topic as solved? It's much easier for other people to find a solution.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft