Mono Support Polls: How to configure polls and Apply CSS like on Page 66 of Documentation (Closed)

Viewed 145864 time(s), 28 post(s), 7/15/2011 12:24:25 AM - by yousaid
7/20/2011 1:04:44 AM
206 Reputation 36 Total posts

Greetings,
Thanks for the codes, but it is throwing the same exceptions as mine. It will not compile and throws same exceptions as mine, see attached.
The attached exception is thrown when I login as admin and click on the Web Parts to lunch the Parts catalog.
Yes, I did recompile the application after I created the codes, but it still throws same exceptions.
Thanks for the clarifications on how to post codes on your forum.
Cheers,

yousaid

Using YOUR codes here is what I have but it will NOT compile

Code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MonoSoftware.MonoX.ModuleGallery
{
    public partial class SitePoll : MonoSoftware.MonoX.ModuleGallery.MonoXPollModule
    {
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            plhLinkButtons.Visible = false;
            btnShowVotePanel.Visible = false;
            btnVote1.Text = this.VoteButtonText;
            btnResults1.Text = this.ResultsButtonText;
            btnShowVotePanel1.Text = this.VoteButtonText;
        }
    }
}

MarkUp
------------
<%@ Control Language="C#"
AutoEventWireup="true"
CodeBehind="SitePoll.ascx.cs"
Inherits="MonoSoftware.MonoX.ModuleGallery.SitePoll"
 
%>
 
 <%@ Register TagPrefix="MonoX" TagName="StyledButton" Src="/MonoX/controls/StyledButton.ascx" %>
 
 <asp:Panel runat="server" ID="pnlContainer">
 <div class="poll">
 <div class="poll-question"><asp:Label runat="server" ID="lblQuestion"></asp:Label></div>
 
 <asp:Panel runat="server" ID="pnlInput">
 <asp:RadioButtonList runat="server" ID="rblAnswers">
 </asp:RadioButtonList>
 
 <div style="margin-top: 10px;">
 <asp:PlaceHolder ID="plhLinkButtons" runat="server" Visible="false">
 <asp:LinkButton runat="server" ID="btnVote" OnClick="btnVote_Click" /> |
<asp:LinkButton runat="server" ID="btnResults" OnClick="btnResults_Click" />
 </asp:PlaceHolder>
 <MonoX:StyledButton ID="btnVote1" runat="server" OnClick="btnVote_Click" />
 <MonoX:StyledButton ID="btnResults1" runat="server" OnClick="btnResults_Click" />
 
 </div>
 </asp:Panel>
 
 <asp:Panel runat="server" ID="pnlGraph" Width="100%">
 <asp:Repeater runat="server" ID="rptGraph">
 <ItemTemplate>
 <asp:Label runat="server" ID="lblAnswer" Text='<%# GetAnswerText(Eval("Answer").ToString(), int.Parse(Eval("Votes").ToString())) %>'></asp:Label><br />
 <asp:Panel runat="server" ID="pnlWidth" BackColor='<%# GetColor(Eval("Color").ToString()) %>' Width='<%# GetWidth(Eval("Votes").ToString()) %>' Height="15px" CssClass='<%# GetColor(Eval("Color").ToString()).Equals(System.Drawing.Color.Empty) ? "poll-bg-color" : String.Empty %>'></asp:Panel>
 </ItemTemplate>
 <SeparatorTemplate>
 <div class="separator">
 </div>
 </SeparatorTemplate>
 </asp:Repeater>
<div style="margin-top: 10px; font-weight: bold;"><asp:Label runat="server" ID="lblTotal"></asp:Label></div>
 
 <asp:LinkButton runat="server" ID="btnShowVotePanel" OnClick="btnShowVotePanel_Click" />
<MonoX:StyledButton ID="btnShowVotePanel1" runat="server" OnClick="btnShowVotePanel_Click" />
 
 </asp:Panel>
 </div>
 </asp:Panel>

11
7/20/2011 10:24:59 AM
3016 Reputation 428 Total posts

Hi,

please use the attached code. "~" sign during the StyledButton control registration was not present in the markup code and that's the reason why it didn't work.

Regards.

12
7/20/2011 10:36:05 AM
15993 Reputation 2214 Total posts

Hi,

Ivan just told me that "~" sign may be lost / trimmed by the code block formatting used on the Mono site, so that may not be the issue here, but the code that he attached was working perfectly (compiling, showing in the module gallery, etc.) on two project that we have tested it, so please try the attached code and get back to us.

Regards

13
7/21/2011 4:19:24 AM
206 Reputation 36 Total posts

Greetings,
Well for what it's worth, here is the solution;

THIS DOES NOT WORK
----------------------------------

public partial class SitePoll : MonoSoftware.MonoX.ModuleGallery.MonoXPollModule
 
Inherits="MonoSoftware.MonoX.ModuleGallery.SitePoll"


THIS WORKS

Notice the UNDERSCORES in the class name and the inherits.
------------------
public partial class MonoX_ModuleGallery_SitePoll : MonoSoftware.MonoX.ModuleGallery.MonoXPollModule
 
Inherits="MonoX_ModuleGallery_SitePoll"

The rest of the code in the download stays the same. I don't know why, but would like to know why the _ in the file name makes a difference.

Thanks
yousaid





14
7/21/2011 7:43:27 AM
15993 Reputation 2214 Total posts

Hi,

I think this is caused by the namespace that we have left (MonoSoftware.MonoX.ModuleGallery) in the code. Sorry about that, anyway you should always use your own namespace in custom Web parts.

I hope the module is working as expected now ?

BTW: I'll answer your direct message shortly.

Regards

15
7/24/2011 6:41:13 PM
206 Reputation 36 Total posts

Greetings,
For some reason, the newly created Web Part is not useable. It shows up in the Parts catalog as expected. However, when selected, and the ADD button is clicked, it throws a NULL reference exception.

Notice in the second image attached that it shows up in the Parts catalog with same name as the existing one (EVEN theough the file name is different)
Question:
Should the existing Web Part with same funtionalities (in this case Poll) be deleted for this to function? I already tried this (on a different machine, but it did not help)

I noticed, this user here http://www.mono-software.com/Mono/Pages/Discussion/dtopic/50HOACxHiEeQbZ7zATjQtQ/Error-trying-to-see-the-webpart-catallog/
had same problem after creating a new web part.
Any ideas on how to resolve this?

cheers,
yousaid

16
7/24/2011 8:39:12 PM
3016 Reputation 428 Total posts

Hi,

can you please attach your SitePool source code and we will check it tomorrow?

Regards.

17
7/24/2011 9:59:24 PM
206 Reputation 36 Total posts

Greetings,


Notice the name of the file is Pollmaster. I created a new file but I get same behavior on both sitepoll and this.

cheers,

yousaid


Codebehind
-------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class MonoX_ModuleGallery_Pollmaster : MonoSoftware.MonoX.ModuleGallery.MonoXPollModule
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        plhLinkButtons.Visible = false;
        btnShowVotePanel.Visible = false;
 
        btnVote1.Text = this.VoteButtonText;
        btnResults1.Text = this.ResultsButtonText;
        btnShowVotePanel1.Text = this.VoteButtonText;
    }
}


Mark Up
--------------

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pollmaster.ascx.cs" Inherits="MonoX_ModuleGallery_Pollmaster" %>
 
 <%@ Register TagPrefix="MonoX" TagName="StyledButton" Src="/MonoX/controls/StyledButton.ascx" %>
  
 <asp:Panel runat="server" ID="pnlContainer">
 <div class="poll">
 <div class="poll-question"><asp:Label runat="server" ID="lblQuestion"></asp:Label></div>
  
 <asp:Panel runat="server" ID="pnlInput">
 <asp:RadioButtonList runat="server" ID="rblAnswers">
 </asp:RadioButtonList>
  
 <div style="margin-top: 10px;">
 <asp:PlaceHolder ID="plhLinkButtons" runat="server" Visible="false">
 <asp:LinkButton runat="server" ID="btnVote" OnClick="btnVote_Click" /> |
<asp:LinkButton runat="server" ID="btnResults" OnClick="btnResults_Click" />
 </asp:PlaceHolder>
 <MonoX:StyledButton ID="btnVote1" runat="server" OnClick="btnVote_Click" />
 <MonoX:StyledButton ID="btnResults1" runat="server" OnClick="btnResults_Click" />
  
 </div>
 </asp:Panel>
  
 <asp:Panel runat="server" ID="pnlGraph" Width="100%">
 <asp:Repeater runat="server" ID="rptGraph">
 <ItemTemplate>
 <asp:Label runat="server" ID="lblAnswer" Text='<%# GetAnswerText(Eval("Answer").ToString(), int.Parse(Eval("Votes").ToString())) %>'></asp:Label><br />
 <asp:Panel runat="server" ID="pnlWidth" BackColor='<%# GetColor(Eval("Color").ToString()) %>' Width='<%# GetWidth(Eval("Votes").ToString()) %>' Height="15px" CssClass='<%# GetColor(Eval("Color").ToString()).Equals(System.Drawing.Color.Empty) ? "poll-bg-color" : String.Empty %>'></asp:Panel>
 </ItemTemplate>
 <SeparatorTemplate>
 <div class="separator">
 </div>
 </SeparatorTemplate>
 </asp:Repeater>
<div style="margin-top: 10px; font-weight: bold;"><asp:Label runat="server" ID="lblTotal"></asp:Label></div>
  
 <asp:LinkButton runat="server" ID="btnShowVotePanel" OnClick="btnShowVotePanel_Click" />
<MonoX:StyledButton ID="btnShowVotePanel1" runat="server" OnClick="btnShowVotePanel_Click" />
  
 </asp:Panel>
 </div>
 </asp:Panel>

18
7/25/2011 8:05:26 AM
15993 Reputation 2214 Total posts

Hi,

can you send us a designer file it seems that some of the controls are not declared (in run-time initialized).

Thanks

19
7/28/2011 3:45:09 AM
206 Reputation 36 Total posts

Greetings,
Unless I am missing something, I don't believe the Website Model that Web Platform Installer installs creates designer files.
Are you using Web Application Project model?
I think Web site model abstracts the ddesigner files and I don't think they exist when you use Web Platform Installer.
You are probably using a Custom project or Web Application Project model.

cheers,
yousaid

20
1 2 3
This is a demo site for MonoX. Please visit Mono Software for more info.