Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0IsEditable and Visble disfunctional?IsEditable and Visble disfunctional?
Previous
 
Next
New Post
8/21/2007 1:14 PM
 

Hi folks,

Got a bit of code in an ascx

<%@ Control Language="VB" Inherits="DESD.Modules.EmploymentListing.EmploymentListView"
    CodeFile="EmploymentListView.ascx.vb" AutoEventWireup="false" Explicit="True" %>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>

    <asp:LinkButton CssClass="CommandButton" ID="cmdDelete" resourcekey="cmdDelete" runat="server"
        BorderStyle="none" Text="Delete" CausesValidation="False" Visible="<%#IsEditable%>"></asp:LinkButton>&nbsp;
                <asp:HyperLink ID="cmdEdit"
                    Visible="<%#IsEditable %>" runat="server">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/edit.gif" AlternateText="Edit"
                        Visible="<%#IsEditable %>" resourcekey="Edit" /></asp:HyperLink>
                <asp:Label runat="server" ID="lblContent"></asp:Label>
<br />
<asp:Label ID="lblTest" runat="server" text="What? "/><% If IsEditable Then%>Hello<%End If%>

Ideas on what I can do to correct this or how I got in this state?

 

In the case of the Delete and Edit links the items are visible regardless of being logged in or not.

That last line of code using the Label will add Hello when logged in, or otherwise nothing when not, just a little thing to see what IsEditable is doing.

 

Just in case it might have some impact on the above, I get to the page that the code runs on via this line of code in the primary control

Response.Redirect(NavigateURL(TabId, "ListingDetails", "Mid=" & ModuleId.ToString, "JobID", JobId.ToString))

it is run through am ItemCommand event against a grid.

 
New Post
8/21/2007 1:30 PM
 

Am I understanding correctly that your problem is that it seems as though your insertions of IsEditable on the three controls aren't doing anything?

The # syntax that you are using in the controls is databinding syntax.  Typically, you'd want to use <%=IsEditable%> (with a = instead of a #), but since you're affecting properties on controls, databinding is your only choice.  In order to get those databinding statements to have any effect, you need to manually databind them, by calling Me.DataBind() inside of your control.

Let me know if that helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
8/21/2007 2:17 PM
 

Forgive me when I say - Huh? I'm just following along with what other modules have in them.

So you're saying I need to BindData them; seems silly, but okay is there an un-obvious reason as to why I would need to do that?

Is there someplace that will guide me as to when to use <% and <#?

Thanks for the assistance, I'll give it a go.

Ewww. got am error when switching <# to <%=

InnerException: Cannot create an object of type 'System.Boolean' from its string representation '<%=IsEditable%>' for the 'Visible' property.
FileName:

Even tried something like this <%=iif(IsEditable = True,'True','False') %>, still got the same error.

 
New Post
8/21/2007 2:33 PM
 

http://msdn2.microsoft.com/en-us/library/k6xeyd4z(vs.80).aspx and http://msdn2.microsoft.com/en-us/library/ms178135(VS.80).aspx cover inline code, http://msdn2.microsoft.com/en-us/library/bda9bbfx(vs.80).aspx covers databinding.

VB appears to be different than C# in how it treats inline code inside of controls.  If you leave your ascx as it was before, and in the code-behind's Page_Load call Me.DataBind(), it should cause those statements to take effect (do you have a code-behind for this control?).  This is my suggestion.  Don't try to switch to <%= %>, just keep doing what you're doing and add a call to Me.DataBind() in your Page_Load.

If you want to keep converting to use non-databinding syntax, then the problem with what have is that the compiler is converting everything into strings.  Your IIF may work if you change the strings to booleans (remove the quotes).

Does that make any more sense?


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
New Post
8/21/2007 3:07 PM
 

I tried iif, gave the same problem. Did Visible="<%=iif(IsEditable,'True','False')%> same error. Don't know how it figured that out since I'm returning a string from inside the iif.

Also tried Visible="<%=iif(IsEditable, Cstr('True'), Cstr('False')) %>"

Went with  Visible=<%=iif(IsEditable, Cstr('True'), Cstr('False')) %> and got a different error about server tags.

Trying Me.DataBind()

Not having read the articles from the links you gave me, it doesn't make sense as to why I would need to do the binding in the first place. If this where PHP I could say Visible="<?=(IsEditable?'True':'False')?>" and get no complaints (save for the fact that I'm guessing at the moment about the ternary expression but that's the general idea).

Anyway, the DataBind did the trick. *sigh* Still seems silly to have to do that just to get something to do what it's suppose to do. :(

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0IsEditable and Visble disfunctional?IsEditable and Visble disfunctional?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out