A RadioButtonList in a GridView

A GridView is to include a RadioButtonList in its presentation. The options are to be populated as fixed options, not taken from a database.

The example below takes values from the DotNetNuke Lists and displays them as a radio button list.

In the presentation file there is a GridView, called gdvMembership

<asp:GridView ID="gdvMembership" runat="server"
  AllowPaging="false"
  AllowSorting="false"
  AutoGenerateColumns="false"
  GridLines="none"
  cellspacing="1"
  border="0"
>
  <Columns>
    <asp:TemplateField ItemStyle-HorizontalAlign="left" ItemStyle-Width="80%">
    <ItemTemplate>
    <asp:RadioButton ID="rbnOptions" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Text")  %>' GroupName='<%# DataBinder.Eval(Container, "DataItem.Value")  %>' Checked='<%# DataBinder.Eval(Container, "DataItem.Selected")  %>' AutoPostBack="true" OnCheckedChanged="setSelection" />
    </ItemTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>

In the code behind, a subroutine is used to populate the GridView and to set the selected item.

Private Sub Registration(ByVal SeclectedValue as string)
  Dim dt as DataTable = new DataTable
  dt.Columns.Add(New DataColumn("Text"))
  dt.Columns.Add(New DataColumn("Value"))
  dt.Columns.Add(New DataColumn("Enabled"))
  Dim row as dataRowrow = dt.newRow()
  row("Text") = "I am registered with the organisation"
  row("Value") = "Registered"
  row("Enabled") = True"
  If SelectedValue Is Nothing Then
    row("Selected") = False
  ElseIf SelectedValue = "Registered" Then
    row("Selected") = True
  Else
    row("Selected") = False
  End If
  dt.Rows.Add(row)row = dt.newRow()
  gdvMembership.DataSource = dt
  gdvMembership.DataBind()
End Sub

Whilst populating the rest of the page content the above sub-routine is called with the value of the registration status.

Registration(objIApplication.Membership)

Radio buttons of a different row in a GridView cannot be grouped together. The issue is caused by each row in the GridView being given a different ident.

The radiobuttons are therefore not of the same name once the page is rendered.

<input id=”dnn_ctr485_application_gdvMembership_rbnOptions_0″ name=”dnn_ctr485_application_gdvMembership_rbnOptions_1″…>

Use the GroupName parameter.

I had considered using JQuery to change uncheck the other options when the selection is changed. However, I chose to use an auto postback and a call to a function: don’t forget to add AutoPostBack=”true”.

Protected Sub setSelection(ByVal sender As Object, ByVal e As System.EventArgs)
  For Each row As GridViewRow In gdvMembership.Rows
    Dim rb As RadioButton = TryCast(row.FindControl("rbnCUOptions"), RadioButton)
    Dim rbn As RadioButton = TryCast(sender, RadioButton)
    If Not rb Is rbn Then
      rb.Checked = False
    End If
  Next
End Sub

Empty the DNN Site Log

An excessively large SiteLog table is likely to have an impact on the performance of your website. Do you know how many entries there are and whether the older ones are being cleaned out?

I have found that the DNN Site log table can be prone to growing, unrestricted.

This can be brought about by the failure to set a day limit and not enabling the scheduled clean up task.

In the past I have found values in the site log which precede the given cut-off date. Often as a result of the number of days being reduced, but the SiteLog purge not running properly.

Maybe looking through the scheduled task notifications you are seeing messages which show the purge of the site log is failing.

Failure of the scheduled task to run is often a sign of a table which has grown too large and is timing out on the deletion.

Information about the site log table SiteLog can be gained via the admin SQL Console.

Empty the DNN site log: count number of rows

SQL is entered within the main text area and run by clicking on Run Script.

Take care! It is easy for an entered command to wipe table contents, beyond the intended results.

The size of the table, ie. the numbers of rows in the table, can be determined by running the command:

SELECT count(*) FROM SiteLog

It’s also possible to see if there are entries earlier than your set limits.

This can be done by running the command

SELECT TOP 10 * FROM SiteLog ORDER BY DateTime DESC

Shown below a typical set of results, based upon a newly enabled sitelog, with the number of columns abbreviated for clarity.

DateTimeReferrerUrlUserAgent
21/03/2018 12:32:00http://localhost/Admin/Site-Settingshttp://localhost/Default.aspx?TabId=67&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
21/03/2018 12:32:00http://localhost/http://localhost/Default.aspx?TabId=56&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
21/03/2018 12:33:00http://localhost/Admin/Site-Settingshttp://localhost/Default.aspx?TabId=67&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
21/03/2018 12:33:00http://localhost/Admin/Log-Viewerhttp://localhost/Default.aspx?TabId=21&portalid=0&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
21/03/2018 12:33:00http://localhost/http://localhost/Default.aspx?TabId=56&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36

If there are entries preceding the cut-off date these may be deleted using

DELETE FROM SiteLog WHERE DateTime < given date

Dates are awkward to deal with. By default entries are stored in American date format. It is also anticipated that dates used will also be in this format too. Rather than adding formatting information when running these commands you may wish to simply accept the default format.

To ensure that you are going to delete the correct items try a selection first, based upon your date range

SELECT * FROM SiteLog WHERE DateTime < CONVERT(DATETIME, ’03/21/2018′)

From my example above I am expecting this to return no results, which is the case.

Whilst setting the date as 22/03/2018 gives:

DateTimeReferrerUrlUserAgent
21/03/2018 12:32:00http://localhost/Admin/Site-Settingshttp://localhost/Default.aspx?TabId=67&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
21/03/2018 12:32:00http://localhost/http://localhost/Default.aspx?TabId=56&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
21/03/2018 12:33:00http://localhost/Admin/Site-Settingshttp://localhost/Default.aspx?TabId=67&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
21/03/2018 12:33:00http://localhost/Admin/Log-Viewerhttp://localhost/Default.aspx?TabId=21&portalid=0&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
21/03/2018 12:33:00http://localhost/http://localhost/Default.aspx?TabId=56&language=en-GBMozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36

You may also wish to sort by the datetime field descending, just to get the newer entries

SELECT TOP 20 * FROM SiteLog WHERE DateTime < CONVERT(DATETIME, ’03/21/2018′) ORDER BY DateTime DESC

It’s possible with too many entries in the SiteLog that the deletion of a range of rows will timeout.

You may wish to purge the SiteLog table. I have found that doing this via the DNN SQL control console can lead to time outs and failure to action.

If the truncation of the table times out or fails then you may find that it’s Better to perform the action via the SQL Server Management Studio, if this is available to you .

I navigate to the required database table view and click on the New Query button.

Enter the following

TRUNCATE TABLE SiteLog

Refresh your table view to see the change in the number of records.

DotNetNuke can require a restart of the application to reflect changes made to the database.

With DNN 9 the site log has been removed. Although it can be added back in if you wish.

Reviewing an older site I observed that the site log still existed.

Without the original admin configuration, it’s not possible to empty the log table by following the older practices to restrict the number of days or to turn off the site log.

I chose to use the SQL truncation detailed above to empty the site log table.

References

A Site Log module: https://github.com/DNNCommunity/Dnn.SiteLog

DNN Browser Compatibility

Older versions of DotNetNuke supported the configuration of the browser compatibility of a website through the file

/js/ClientAPICaps.config

The operation of the default DotNetNuke SolPart menu with regard to different browsers is governed by this file.

The file is divided into a number of sections, for example:

<functionality nm="DHTML" desc="Dynamic HTML">
  <supports>
    <browser nm="IE" minversion="4" />
    <browser nm="FireFox" minversion="1" />
    <browser nm="Netscape" minversion="5" />
    <browser nm="Gecko" minversion="1" />
    <browser nm="Opera" minversion="7" />
    <browser contains="Iceweasel" />
    <browser contains="Konqueror" />
    <browser contains="Safari" />
    <browser contains="Camino" />
  </supports>
  <excludes>
  </excludes>
</functionality>

In the example given above I have added support for the Konqueror and Iceweasel browsers.

I created an HTML file with the following content to get the details of the browser.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
  <title>Untitled Page</title>
</head>
<body>
  <script>alert(navigator.userAgent.toLowerCase());</script>
</body>
</html>

I experimented with the browser compatibility options. As mentioned above, adding references for support of lesser used browsers. But found that realistically it added an additional complication to preparing a website. And with websites continually evolving it was going to be an overhead to maintaining websites. After my experimentation I no longer edited the browser configuration, leaving the file as is.

Whilst writing and updating the content of this article I was curious to see whether the file was still included, and if so what it contained. Looking at the latest version on GitHub I found that its content was similar:

<?xml version="1.0" encoding="utf-8" ?>
<capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <functionality nm="DHTML" desc="Dynamic HTML">
    <supports>
      <browser nm="IE" minversion="4" />
      <browser nm="FireFox" minversion="1" />
      <browser nm="Netscape" minversion="5" />
      <browser nm="Gecko" minversion="1" />
      <browser nm="Opera" minversion="7" />
      <browser nm="Mozilla" minversion="1" />
      <browser contains="Konqueror" />
      <browser contains="Safari" />
      <browser contains="Camino" />
      <browser contains="Mozilla" />
    </supports>
    <excludes>
    </excludes>
  </functionality>

Not much has changed with the start of this file over the years.

DNN 9 Where’s the Allowable File Extensions?

Is the Allowable File Extensions in DNN 9 missing or simply hidden?

The good news is that it’s still available.

The Allowable File Extensions is a list of those file types configured by their file extension which are permitted to be uploaded to the website.

It’s given as a comma separated list within the site’s admin configuration.

Previously it was to be found under the Host > Site Settings page.

DNN 9 Wheres the allowable file extensions? old config option

Looking under the site configuration in DNN 9 I was unable to see the Allowable File Extensions configuration textbox.

It’s still there, but now moved under the Security option.

Begin by selecting the Security menu from the options on the left black panel

DNN 9 Wheres the allowable file extensions? Select security menu

On the security menu select the more tab at the right hand end. Opening this section.

DNN 9 Wheres the allowable file extensions? Security menu

On this tab we have the options for SSL Settings and still More Security Settings. This is the one which we are interested in. Click on it.

DNN 9 Wheres the allowable file extensions? More security settings

Finally we have the page which we are interested in, More Security Settings.

DNN 9 Wheres the allowable file extensions? Security menu more tab

Scroll down the page to the last textbox which shows a list of the different file types which are supported. Add or remove to suit your website requirements.

The Allowable File Extensions isn’t lost/missing. It has been moved under the Security menu section.

The Remote Certificate is Invalid

Configuring the SMTP settings on a DotNetNuke website gave the error, remote certificate is invalid, from the mail server:

There has been an error trying to send the test email. The error is:
The remote certificate is invalid according to the validation procedure

I often find that errors on a DotNetNuke website are logged with further information in the Event Log. To view this navigate to Admin/Event Viewer, from the top navigation bar.

Dependant upon how many messages are created on your website, for example users logging in, the error message which you are looking for may be on the second or third page. If necessary take a note of the time and force the error again, to get it on the first page.

In the Event Viewer log the gist of the error message was:

There has been an error trying to send the test email. The error is:
The message was not delivered to the following address(es) –

I found error relay not permitted.

Where the SMTP host settings for the DotNetNuke installation is configured to use a defined mailbox if choosing to use a secure connection the domain name of the certificate and mail account needs to be the same domain as that configured in the settings.

The error may be resolved by either using a mailbox with the correct domain certificate. or by using an unsecured mailbox and unticking the SSL option.

DotNetNuke How to Add alt Text to an Image

Alt text can be added to a DotNetNuke image either at the time of adding the image to the text content, or subsequently if required.

DotNetNuke manages uploaded images and documents through the File Manager.

I prefer to use the file manager to upload and manage my images and documents separately from when inserting content to the page.

With the background work done, images and documents uploaded, I can compose my content for the page, without the disruption involved in uploading an image.

While composing the page content I can click on the image icon within the editor to popup the Image Manager dialogue to make my selection.

DotNetNuke adding image alt text add media

Using the popup Image Manager navigate to and select the image which you wish to insert into your text.

DotNetNuke Adding Image Alt Text

Add further details regards the image, for example the size of the image, width or height, and the element which we are interested in the alt text.

Later on, if you decide to change the text right click on the image to select the properties option, this will open the Properties dialogue.

DotNetNuke adding image alt text image properties

Why add ALT Text to an Image? Well adding alt text to an image is good for SEO, lets visitors understand the context in which you are using the image and for those who are using a screen reader to view your website the text will be spoken.

Increase the DotNetNuke Maximum File Upload Size

I find the default limit on file upload size in DotNetNuke can be too restrictive.

The default DNN upload file size is 8Mb.

The setting is within the web.config file in the root of the DNN website file installation.

Look for the section <system.web>.

    <!-- allow large file uploads -->
    <httpRuntime useFullyQualifiedRedirectUrl="true" maxRequestLength="8192" requestLengthDiskThreshold="8192" />

Increase the value of the maxRequestLength parameter to clear the file size which is an issue. Doubling to 16M may be sufficient.

    <!-- allow large file uploads -->
    <httpRuntime shutdownTimeout="120" executionTimeout="900" useFullyQualifiedRedirectUrl="true" maxRequestLength="16284" requestLengthDiskThreshold="16384" requestValidationMode="2.0" requestPathInvalidCharacters="<,>,*,%,:,\,?" fcnMode="Single" />
    <httpCookies httpOnlyCookies="true" requireSSL="false" domain="" />

To edit the file download a copy from the server via FTP using Filezilla. The file can then be edited with a text editor such as notepad.

For simplicity of editing with colour discrimination of tags and parameters you may find one of the HTML editors useful. Must admit if it’s a one off then whatever editor is to hand is the best option.

At the time you are downloading this one configuration file why not take a backup of the whole website?

With an increased file size capability it will take longer to upload the files to your website. You may also wish to increase this time out.

If you are experiencing file upload restrictions on images then maybe you should reconsider the size or quality of the image which you are uploading. Larger, slow to load images, can have a detrimental effect on your website, visitors maybe become impatient leaving slow to load pages and it is considered a black mark on your SEO score.

References

DNN Software: Working with large files

DNN FAQ Unknown Server Tag dnn:DnnListBox

Catching up with DotNetNuke site updates I observed an error on a page with the FAQ module installed.

The website had been updated to DNN 8.0.4.

Bellow is the DNN FAQ module error

DotNetNuke.Services.Exceptions.ModuleLoadException: Unknown server tag 'dnn:DnnListBox'. ---> System.Web.HttpParseException: Unknown server tag 'dnn:DnnListBox'. ---> System.Web.HttpParseException: Unknown server tag 'dnn:DnnListBox'. ---> System.Web.HttpException: Unknown server tag 'dnn:DnnListBox'. at System.Web.UI.TagPrefixTagNameToTypeMapper.System.Web.UI.ITagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs) at System.Web.UI.MainTagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs, Boolean fAllowHtmlTags) at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty) at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.WebFormsModuleControlFactory.CreateModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration) at DotNetNuke.UI.Modules.ModuleControlFactory.LoadModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---

I visited the DNN FAQ module on github, downloaded and installed the more recent updated version 08.04.00.

The error was gone!

Catalook Store Module Guest User Checkout

The DotNetNuke Catalook store module offers the option to complete the purchase with a guest account.

If you are running an online shop you may prefer to allow transactions to be completed without the visitor creating an account.

Forcing the website visitor to create an account as a part of an online shop payment process may lose a few potential customers. Creating an account may be one hurdle too many.

For a DNN website running the Catalook shop module the option to run using guest accounts isn’t configured within the Catalook settings.

To allow guest user check out the Catalook store on DNN requires that site settings User Account options is set to allow public user registrations.

Catalook Guest User Checkout User Account Settings

To enable public registration open the admin Site Settings page.

On this page select the User Accounts tab.

As shown in the image above from the Registration Settings section, from the user registration options select public.

With the public option selected when a visitor completes the purchase transaction on your Catalook shop module no user account registration is required.

DNN Login Link not Showing

Configuring a DNN website to show a login link. A small change to implement but where is the relevant checkbox?

Reconfiguring a DNN website to show the login link I was looking to reintroduce the login link.

The code for the skin included the references for the login/logout and user profile/register references.

Open the admin site settings page.

Whilst it may be tempting to look at the User Options the display of the login link is considered to be a security aspect.

On the admin Site Settings page open the advanced settings tab and look in the security settings section.

DNN login link not showing

Looking at this section the Hide Login Control checkbox is un ticked if the login link is to be shown.

Click on update at the bottom of the page to save changes made.

To check whether the login link was showing I viewed the website in another browser on which I hadn’t logged in.