MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

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

Viewed 75684 time(s), 28 post(s) 7/15/2011 12:24:25 AMby yousaid

Related topics

yousaid

yousaid

7/20/2011 1:04:44 AM
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>
This content has not been rated yet. 
206 Reputation 36 Total posts
imarusic

imarusic

7/20/2011 10:24:59 AM
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.
Rated 5.00, 1 vote(s). 
3016 Reputation 428 Total posts
khorvat

khorvat

7/20/2011 10:36:05 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts
yousaid

yousaid

7/21/2011 4:19:24 AM
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





This content has not been rated yet. 
206 Reputation 36 Total posts
khorvat

khorvat

7/21/2011 7:43:27 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts
yousaid

yousaid

7/24/2011 6:41:13 PM
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
This content has not been rated yet. 
206 Reputation 36 Total posts
imarusic

imarusic

7/24/2011 8:39:12 PM
Hi,

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

Regards.
This content has not been rated yet. 
3016 Reputation 428 Total posts
yousaid

yousaid

7/24/2011 9:59:24 PM

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>
This content has not been rated yet. 
206 Reputation 36 Total posts
khorvat

khorvat

7/25/2011 8:05:26 AM
Hi,

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

Thanks
This content has not been rated yet. 
15993 Reputation 2214 Total posts
yousaid

yousaid

7/28/2011 3:45:09 AM
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
This content has not been rated yet. 
206 Reputation 36 Total posts
1 2 3