Note that there are some explanatory texts on larger screens.

plurals
  1. POWebforms: Inline Literals in .ascx preventing compilation
    primarykey
    data
    text
    <p>I have the following snippit in my .ascx file:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="MyCompany.Modules.Discovery.ViewDiscovery" AutoEventWireup="true" CodeBehind="ViewDiscovery.ascx.cs" %&gt; &lt;div id="ViewDiscovery_&lt;asp:Literal ID="litModuleId" runat="server" /&gt;"&gt;&lt;/div&gt; &lt;script type="text/javascript" src="&lt;asp:Literal ID="litControlPath" runat="server" /&gt;carousel-jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="&lt;asp:Literal ID="litControlPath2" runat="server" /&gt;discovery-widget.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { var myData = &lt;asp:Literal ID="litContent" runat="server" /&gt;; var myDiscovery = discovery('&lt;asp:Literal ID="litControlPath3" runat="server" /&gt;'); myDiscovery.json(myData); myDiscovery.init("ViewDiscovery_&lt;asp:Literal ID="litModuleId2" runat="server" /&gt;"); }); &lt;/script&gt; </code></pre> <p>As you might be able to infer from the syntax highlighting (or rather, how broken it is), if I try to compile my CodeBehind file with this .ascx file, it fails horribly because it doesn't recognize the various literals that I have sprinkled around in the file, and thus my codebehind file fails to compile. I have to remove them from their positions, put them at the end of the file unencumbered by their context in the page, compile, then revert to the original version.</p> <p>Surely there is nicer way of going about putting literals in the page.</p> <p><strong>EDIT:</strong> When I package my module up and install it on another instance of DotNetNuke (it works fine locally as long as I do that rigamarole when I compile it), it throws an error:</p> <pre><code>DotNetNuke.Services.Exceptions.ModuleLoadException: The tag contains duplicate 'ID' attributes </code></pre> <p>Related, or is there some other issue going on here?</p> <p><strong>EDIT</strong>: I have tried to use <code>&lt;%=variable %&gt;</code> but haven't gotten anywhere. This is a snippit from my codebehind:</p> <pre><code>namespace MyCompany.Modules.Discovery { partial class ViewDiscovery : PortalModuleBase, IActionable { public string strContent = "Insert Content Here!"; protected void Page_Load(object sender, System.EventArgs e) { // Do stuff here! this.strContent = "My content!"; } } } </code></pre> <p>If I then do this in my ascx file:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="MyCompany.Modules.Discovery.ViewDiscovery" AutoEventWireup="true" CodeBehind="ViewDiscovery.ascx.cs" %&gt; &lt;%=this.strContent %&gt; </code></pre> <p>...nothing shows up on my page. A peek at the context of 'this' in the .ascx file reveals it to be of type "ASP.viewdiscovery_ascx", not "ViewDiscovery" as I expected.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload