More in this section

Forums / Developing with Sitefinity / User control's events are not firing.

User control's events are not firing.

7 posts, 0 answered
  1. Joel
    Joel avatar
    4 posts
    Registered:
    07 Oct 2007
    08 Nov 2007
    Link to this post
    I have a custom login control that I added to my home page which the home page was built in the sitefinity admin area and the user control was uploaded and added after that.

    When I tried to add event to my server button, I noticed that the server button doesn't trigger the page to postback instead is a fresh load everytime. This cause my event handler will never get triggered.

    Is this behavior normal? What should I do if I want to write my own custom code to my user control?
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    08 Nov 2007
    Link to this post
    Hi Joel,

    Could please send us the control causing the problem to test it locally as we can't reproduce the described behavior?

    In the attachment you could find a very simple custom control (it contains a button and a label). When you click the button, the label fills. Could you check if you have any problems with the attached control?

    Thanks for your cooperation in advance.

    Regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Joel
    Joel avatar
    4 posts
    Registered:
    07 Oct 2007
    08 Nov 2007
    Link to this post
    Hi Pepi,

    Thanks for your reply.

    Here is my code:

    <%@ Control Language="C#" ClassName="ucLogin" %>

    <script runat="server">

    protected void ibtnGo_Click(object sender, ImageClickEventArgs e)

    {

    Membership.ValidateUser(txtUserName.Text, txtPassword.Text);

    }

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    </script>

    <asp:Panel ID="pnlLogin" runat="server">

    <div id="LoginWrapper">

    <div style="margin-left: 195px; padding-top: 5px;">

    <asp:ImageButton ID="ibtnRegister" runat="server" ImageUrl="~/Images/transpace.gif"

    Width="62px" Height="21px" BorderWidth="1" BorderColor="transparent" PostBackUrl="~/Register.aspx" />

    </div>

    <div style="margin-left: 88px; margin-top: 5px; * margin-top: 1px;">

    <asp:TextBox ID="txtUserName" runat="server" Width="165px" BorderWidth="1" Font-Names="Arial"

    ForeColor="#808080" BackColor="transparent" BorderColor="transparent">

    </asp:TextBox>

    </div>

    <div style="margin-left: 88px; margin-top: 7px; * margin-top: 3px;">

    <asp:TextBox ID="txtPassword" runat="server" Width="135px" BorderWidth="1" Font-Names="Arial"

    ForeColor="#808080" TextMode="Password" BackColor="transparent" BorderColor="transparent">

    </asp:TextBox>

    </div>

    <div style="margin-left: 228px; margin-top: -21px; * margin-top: -22px;">

    <asp:ImageButton ID="ibtnGo" runat="server" ImageUrl="~/Images/transpace.gif" Width="29px"

    Height="23px" BorderWidth="1" BorderColor="transparent" OnClick="ibtnGo_Click" />

    </div>

    <div style="margin-left: 88px;">

    <asp:ImageButton ID="ibtnRetrievePassword" runat="server" ImageUrl="~/Images/transpace.gif"

    Width="120px" Height="12px" BorderWidth="1" BorderColor="transparent" />

    </div>

    </div>

    </asp:Panel>


    I modified this code after I uploaded my user control and added it to the page.

    I am now facing another problem, I can't "Edit", "Publish" and "Cancel Changes". I can see the edit page, but when I tried to change anything on that page like editing a user control or deleting the user control, nothing seems to happen. I can't even cancel the changes or publish the page again. The page just reload the itself.

    It was working fine the day before I tried out the Nolics. I was working on Nolics yesterday. I installed nolics that I downloaded from my client.net then I created a project with Nolics and added the project to my Sitefinity solution. I managed to add a new connection to the Nolics project and added the reference from my sitefinity project. The dbclass works fine in the sitefinity project, I could insert and retrieve the data ok. When I come back to the user control, then i realised the new event that I added wasn't firing, and then all the problems started arising. I am not sure if it is Nolics that caused the issue. Because the Nolics that I downloaded is v4.2.2520.4 instead of the v4.2.2522.4 that the sitefinity 3.1 is using. I had to downgrade the v4.2.2522.4 to v4.2.2520.4 in the sitefinity project. 

    I have tried removing all the changes that the Nolics added to the web config and un-reference my nolics project and commented out all the nolics code in my sitefinity project. And also uninstalled Nolics then uninstalled the sitefinity 3.1 SP1 and reinstalled it. But nothing seems to works, the problems are still persist.

    But the same project that I deployed to my staging server works very well, nothing goes wrong there. It is the same code that I have in my local machine.

    This problem seems fairly strange. I might have done something that caused this. Right now I am just trying to get the same codes that works on my staging server to work on my local machine. I have a clean version of the sitefinity 3.1 SP1 installed in my machine and no Nolics. Could you please advise what I should do next?

    Cheers,
    Joel




  4. Joel
    Joel avatar
    4 posts
    Registered:
    07 Oct 2007
    09 Nov 2007
    Link to this post
    I have rolled back to my pervious version. Everything started to work now. It's all good now.

    I am really not sure what was going on.

    I will try to re-install Nolics and play around with it again.
  5. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    09 Nov 2007
    Link to this post
    Hi Joel,

    We succeeded in reproducing the described behavior. Try setting resetUrlMode="None" in the cms section of your we.config file. For example:

    <cms defaultProvider="Sitefinity"  
         pageExtension=".aspx"  
         siteTemplate="" 
         projectName="Sitefinity_3.1"  
         disabled="false"  
         pageEditorUIMode="Overlay"  
         resetUrlMode="None"

    This should fix the problem with event firing.

    Let us know how it goes.

    Regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Joel
    Joel avatar
    4 posts
    Registered:
    07 Oct 2007
    12 Nov 2007
    Link to this post
    Hi Pepi,

    Thanks for your reply.

    Tried using that, but it throws me an exception:

    -------------------------

    Invalid Page request! The CMS entry point should never be called directly.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Invalid Page request! The CMS entry point should never be called directly.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:


    [HttpException (0x80004005): Invalid Page request! The CMS entry point should never be called directly.]
       Telerik.Cms.Web.InternalPage.OnPreInit(EventArgs e) +708
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +521

    -----------------------

    Anyway, I figured out what went wrong with my project. It was the PostBackUrl in one of my image button in the user control that caused the problem. I guess it is some compilation issue with the user control, caused the page that I want the image button to post back to is a dynamic sitefinity page, it doesn;t exists in my project.

    I had to use post back event to redirect to the page instead of defining it in the properties.

    Here is my new code that works: 

    <%@ Control Language="C#" ClassName="ucLogin" %>

     

    <script runat="server">

     

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!IsPostBack)

    {

    mLogin.MembershipProvider = Telerik.Security.UserManager.Default.MembershipProvider.Name;

    }

    if (Telerik.Security.UserManager.GetCurrentUser().IsInRole(AppHelper.CookBookUserRoleName))

    {

    spLoginUser.InnerHtml = string.Format("{0} {1}", Profile.FirstName, Profile.LastName);

    mvLogin.SetActiveView(vLogout);

    }

    }

    void mLogin_Authenticate(object sender, AuthenticateEventArgs e)

    {

    e.Authenticated = Telerik.Security.UserManager.Default.ValidateUser(mLogin.UserName, mLogin.Password);

    }

    void mLogin_LoggedIn(object sender, EventArgs e)

    {

    HttpCookie cookie = this.Response.Cookies[FormsAuthentication.FormsCookieName];

    Telerik.Security.UserManager.Default.SetAuthenticationCookie(cookie);

    spLoginUser.InnerHtml = string.Format("{0} {1}", Profile.FirstName, Profile.LastName);

    mvLogin.SetActiveView(vLogout);

    }

    protected void lbtnLogout_Click(object sender, EventArgs e)

    {

    System.Web.Security.FormsAuthentication.SignOut();

    mvLogin.SetActiveView(vLogin);

    }

    protected void ibtnRegister_Click(object sender, ImageClickEventArgs e)

    {

    Response.Redirect("~/Register.aspx");

    }

     

    </script>

    <asp:Panel ID="pnlLogin" runat="server">

     

    <div id="LoginWrapper">

     

    <asp:MultiView ID="mvLogin" runat="server" ActiveViewIndex="0">

     

    <asp:View ID="vLogin" runat="server">

     

    <asp:Login ID="mLogin" runat="server" OnAuthenticate="mLogin_Authenticate" OnLoggedIn="mLogin_LoggedIn">

     

    <LayoutTemplate>

     

    <div id="LoginLayout">

     

    <div style="margin-left: 195px; padding-top: 5px;">

     

    <asp:ImageButton ID="ibtnRegister" runat="server" ImageUrl="~/Images/transpace.gif"

     

    Width="62px" Height="21px" BorderWidth="1" BorderColor="transparent" OnClick="ibtnRegister_Click" />

     

    </div>

     

    <div style="margin-left: 88px; margin-top: 5px; * margin-top: 1px;">

     

    <asp:TextBox ID="UserName" runat="server" Width="165px" BorderWidth="1" Font-Names="Arial"

     

    ForeColor="#808080" BackColor="transparent" BorderColor="transparent">

     

    </asp:TextBox>

     

    </div>

     

    <div style="margin-left: 88px; margin-top: 7px; * margin-top: 3px;">

     

    <asp:TextBox ID="Password" runat="server" Width="135px" BorderWidth="1" Font-Names="Arial"

     

    ForeColor="#808080" TextMode="Password" BackColor="transparent" BorderColor="transparent">

     

    </asp:TextBox>

     

    </div>

     

    <div style="margin-left: 228px; margin-top: -21px; * margin-top: -22px;">

     

    <asp:ImageButton ID="Login" runat="server" ImageUrl="~/Images/transpace.gif" Width="29px"

     

    Height="23px" BorderWidth="1" BorderColor="transparent" CommandName="Login" />

     

    </div>

     

    <div style="margin-left: 88px;">

     

    <asp:ImageButton ID="ibtnRetrievePassword" runat="server" ImageUrl="~/Images/transpace.gif"

     

    Width="120px" Height="12px" BorderWidth="1" BorderColor="transparent" />

     

    </div>

     

    </div>

     

    </LayoutTemplate>

     

    </asp:Login>

     

    </asp:View>

     

    <asp:View ID="vLogout" runat="server">

     

    <div id="LogoutLayout">

     

    <h2>

     

    <span id="spLoginUser" runat="server" style="color: #C80000;"></span>

     

    </h2>

     

    <asp:LinkButton ID="lbtnLogout" runat="server" Text="Logout" OnClick="lbtnLogout_Click"></asp:LinkButton>

     

    </div>

     

    </asp:View>

     

    </asp:MultiView>

     

    </div>

    </asp:Panel>

    As the result there is nothing to do with Nolics. I can now use my nolics objects together with sitefinity. Hooray!!

    Also, instead of downgrading the Nolics Engine, I have upgraded it to use v4.2.2522.4.

    <
    runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

    <probing privatePath="bin;sitefinity\admin\bin"/>

    <dependentAssembly>

    <assemblyIdentity name="Nolics.Engine.v4.2" publicKeyToken="c50af72fde0670b7" culture="neutral"/>

    <bindingRedirect oldVersion="4.2.2520.4" newVersion="4.2.2522.4"/>

    </dependentAssembly>

    </assemblyBinding>

    </runtime>

    Let's hope it won't cause any more problems. Fingers crossed!! :)

    Cheers,
    Joel


  7. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    12 Nov 2007
    Link to this post
    Hello Joel,

    I am glad to hear that everything is running as expected now. Let us know if you come across any other difficulties.

    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
7 posts, 0 answered