Copied to clipboard

Flag this post as spam?

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


  • Arnaudov 5 posts 25 karma points
    Oct 24, 2012 @ 12:14
    Arnaudov
    0

    no action after postback in custom user control

    Hello everyone -

    I am trying to include user control which has a simple textbox, button and literal control.

    The text in the textbox should be set in the literal control once user clicks the button but nothing is happening at this moment.

    This is the content of the user control:

     

    <%@ Control Language="C#" EnableViewState="true" AutoEventWireup="true" CodeBehind="FreeQuoteForm.ascx.cs" Inherits="UmbracoContacts.FreeQuoteForm" %>

    <span style="color:Black">Your name:</span> <asp:TextBox style="border:1px solid" ID="txtName" runat="server" />&nbsp;&nbsp;<asp:Button Text="Submit" ID="btnSubmit" runat="server"
        onclick="btnSubmit_Click" />
    <br />
    <span style="color:Black"><asp:Literal ID="litText" runat="server" /></span>

    The code behind has this:

     

    namespace UmbracoContacts
    {
        public partial class FreeQuoteForm : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                litText.Text = "Enter Name"; 
            }

            protected void btnSubmit_Click(object sender, EventArgs e)
            {
                litText.Text = txtName.Text;
            }
        }
    }

    Once I am done with that part, I am uploading the usercontrol.ascx file in usercontrols folder and the dll of the project in the umbraco bin folder.

    Here is the template file I am using:

     

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
       
    <!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 runat="server">
        <title><umbraco:Item field="pageName" runat="server" /></title>
        <!-- Font -->
        <link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz">
        <!-- Style -->
        <link type="text/css" rel="Stylesheet" media="all" href="/css/Style.css" />
        <link type="text/css" rel="Stylesheet" media="all" href="/css/Resset.css" />
        <!-- Favicon -->
        <link rel="shortcut icon" type="image/x-icon" href="/media/69/Logo/favicon.png" />
        <!-- Javascript -->   
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
       
        <body class="bg">
        <form id="form1" runat="server">
        <!-- START Wrapper -->
        <div class="wrapper">
            <!-- START Header -->
            <div class="header">
                <div class="logo">
                 <!--  <a href="http://7a7.co"><img src="/media/74/logo.png" alt="7a7" /></a> -->
                </div>
                <div class="topnav">
                    <ul id="nav-sub">               
                    </ul>
                </div>
            </div>
            <!-- END Header -->
            <!-- START Navigation -->
            <div class="navigation">
            <ul class="nav">     
            </ul>
            </div>
            <!-- END Navigation -->
            <!-- START Left Sidebar -->
            <div class="left-sidebar">
                <div class="tags-clients">
                    <h1><asp:Label ID="lblTagsTitle" runat="server" Text="Tags"></asp:Label></h1>
                    <div class="content">
                        <ul class="list-tags">               
                        </ul>
                    </div>
                </div>
                <div class="our-clients">
                    <h1><asp:Label ID="lblOurClientsTitle" runat="server" Text="Our Clients"></asp:Label></h1>
                    <div class="content">              
                    </div>               
                </div>
                <div class="cloud-clients">             
                </div>
            </div>
            <!-- END Left Sidebar -->
              <div class="main">
                <asp:ContentPlaceHolder Id="contentPlaceholderPage" runat="server">
                    <!-- Insert default "contentPlaceholderPage" markup here -->
                  </asp:ContentPlaceHolder>
            </div>   
            <!-- START Footer -->
            <div class="footer">
            </div>
            </div>
            <!-- END Footer -->
        </div>
        <!-- END Wrapper -->
     </form> 
    </body>
    </asp:Content>

    You can find the page here: http://www.7a7.co/free-quote.aspx

     

    Any help or advice will be helpful because this is dragging too much now and I really need to complete.

    Thanks

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 24, 2012 @ 15:48
    Alex Skrypnyk
    0

    Hi Arnaudov,

    Try this one:

    if (!IsPostBack)

                {

                    litText.Text = "Enter Name";

                }

     

  • Arnaudov 5 posts 25 karma points
    Oct 24, 2012 @ 15:52
    Arnaudov
    0

    Alex, same.

    Doesn't help :(

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 24, 2012 @ 15:56
    Alex Skrypnyk
    0
    EnableViewState="true"

    Why you use this ?

    ViewState is disabled in your site ?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 24, 2012 @ 15:58
    Alex Skrypnyk
    0

    try to add :

     

        protected void Page_Init(object sender, System.EventArgs e)
        {
            this.EnableViewState = false;
        }
    
    
  • Arnaudov 5 posts 25 karma points
    Oct 24, 2012 @ 16:00
    Arnaudov
    0

    I removed the enableviewstate=true from the header of the user control, should I still add the page_init code?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 24, 2012 @ 16:01
    Alex Skrypnyk
    0

    Yes, please 

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 24, 2012 @ 16:01
    Alex Skrypnyk
    0

    do you enter in Click event in debug mode ?

  • Arnaudov 5 posts 25 karma points
    Oct 24, 2012 @ 16:22
    Arnaudov
    0

    I do when I am using the user control in local aspx page but not when I am using the control in the umbraco CMS :(

  • Arnaudov 5 posts 25 karma points
    Oct 24, 2012 @ 16:36
    Arnaudov
    0

    Alex what I noticed just know is when I am opening the source of http://www.7a7.co/free-quote.aspx I can see the form is not runat="server', although in the template as you can see I specified that the form is runat="server".

    Maybe that might lead to something?

    Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies