You are here: Craig > CodeCharge Studio

Change the RedirectUrl of an object and add a URL Parameter

The need for this code came from a record form that needed to have a Save button that saved a new record but continued to display the form in Update mode with the newly saved record.  For all of my tables I use an Identity column for the primary key.  For this to be possible I need another column in the table that is unique.


Note: I also use CodeSmithTools and NetTiers to generate a Data Access Layer (DAL).


The following code assumes I've retrieved the record that was just saved (using the generated DAL) and now I'm going to update the RedirectUrl of the record form.  BP is the record object from the DAL.


   Dim S As Session = DataRepository.SessionProvider.GetBySessionName(Session.GetControl(Of MTTextBox)("SessionName").Text)
   If Not S Is Nothing Then
    Session.RedirectUrl.Address = "session_form.aspx"
    Dim up As New InMotion.Web.Controls.UrlParameter
    up.Name = "SessionID"
    up.Value = S.SessionID.ToString()
    Session.RedirectUrl.Parameters.Item("SessionID") = up
   End If

Implement ReturnUrl when calling form from multiple places.

I had a situation where I had to call the same record form from multiple grid pages and I wanted to return to the calling page.  To accomplish this I implemented a ReturnUrl similar to how the security works when you are redirected to the Login page and then returned to the calling page.


In the edit and add links on the grid page I added a Link Parameter:


Source Type: Expression

Parameter Source: "session_list.aspx"

Parameter Name: ReturnUrl


Then in the After Initialize event of my record page I added the following code (Session is the name of my record form):


  If Not String.IsNullOrEmpty(Request.QueryString("ReturnUrl")) Then
   Session.RedirectUrl.Address = Request.QueryString("ReturnUrl")
  End If


Then for each of the form buttons (Add, Submit, Delete & Cancel) I add ReturnUrl to the Remove Parameters property.

Accessing Controls from Javascript

Below is some sample javascript code hiding/showing controls from Javascript when using the InMotion framework.


 if (getMTControl("Batch.BatchCodeEditLink")) getMTControl("Batch.BatchCodeEditLink").style.display = 'none';

if (getMTControl("Batch.BatchCodeLabel")) getMTControl("Batch.BatchCodeLabel").style.display = 'none';

if (getMTControl("Batch.BatchCode")) getMTControl("Batch.BatchCode").style.display = 'block';

Access Controls in Grid from Image Button OnClick

Dim tb As MTTextBox = CType(sender, MTImageButton).Parent.FindControl("NameOfControl")

Using the AjaxControlToolkit in a .Net InMotion App

  1.  Rename InMotion.Web.Features.dll to InMotion.Web.Features.Orig.dll.  This file is located in Program Files/CodeChargeStudio4/Components/CodeTemplates/VBInMotion/Library (or C#InMotion if you are using C#).
  2. Download and unzip this file and put it in same directory as the file you renamed.  In this .dll I changed the MTScriptManager to inherit from ToolkitScriptManager instead of ScriptManager. 
  3. Download and copy the AjaxControlToolkit .dlls (I'm using the 3.5 version) to the bin folder of your website.
  4. Within CodeCharge in the web.config add the following section within <system.web>


    <add tagPrefix="mt" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />


5. On a page in CodeCharge change to HTML view and insert an AjaxControlToolkit control.


I've only tested the CalendarExtender with the following line of code.


<mt:calendarextender id="CalendarExtender1" runat="server" targetcontrolid="s_StartDate" format="d" />


Redirecting to an SSL page

To have your codecharge site redirect to an SSL page for all pages, place the following code in the Application_BeginRequest method in Global.asax:


  If Not Request.IsSecureConnection Then
   Response.Redirect(Request.Url.AbsoluteUri.Replace("http://", "https://"))
  End If


Using CKEditor

Well, sometimes things are sooooooooooo simple. We just incorporated the latest CK Editor into one of our C# Inmotion Projects.

Here is how to do it:

(1) Upload the latest CK Editor Version to the root of your webserver

(2) Create a Record and make sure the field you want to use for the CK Editor is a TEXT AREA. Open the page and switch to HTML View

(3) Add the following script line between the <head></head>
<script type="text/javascript" src="/dnn/Portals/9/./ckeditor/ckeditor.js"></script>
Make sure that the path to the ckeditor.js script is accurate !!

(4) Add the CK Editor Class to the Text Area. It should look as follows:
<textarea class="ckeditor" id="TextareaID" rows="3" cols="50" name="{Work_Desc_Name}">{Work_Desc}</textarea></td>


(1) Using the BASIC Toolbar
Add <script>CKEDITOR.config.toolbar='Basic'</script> BEFORE the text area. There are two toolbars right now. If you don't add this script line then the default toolbar will be used.

It should like like:

<td><textarea class="ckeditor" id="TextareaID" rows="3" cols="50" name="

(2) Using a different SKIN
Add <script>'v2'</script> BEFORE the text area. "v2" is the skin name. Right now there are only three skins available.

It should look like:

<td><textarea class="ckeditor" id="TextareaID" rows="3" cols="50" name="

Compile and upload and you are ready to roll. So bloody simple. And the CK Editor is so much faster and precise than the stone old FCK Editor.

Link to forum post:


For protected sites you'll need to Set Validate Request to false.

For .Net Framework 4 sites you'll need to add


<httpRuntime requestValidationMode="2.0" />


To the system.web section of the web.config.



Force Page Break after Footer

<!-- BEGIN Section SessionBreak_Footer -->
        <tr style="PAGE-BREAK-AFTER: always" class="SubTotal">
          <td colspan="4">Sub Total&nbsp;{Count_ClientLastFirst1}</td>
          <td style="TEXT-ALIGN: right" valign="baseline">{Sum_BillAmount1} </td>
 <!-- END Section SessionBreak_Footer -->

Retrieve Value of Recordset Field

Per Yes Software support... To retrieve the value of a recordset field, or a field that is part of the datasource query but not assigned to a control in your grid or record.

Grid BeforeShowRow:
DirectCast(sender, InMotion.Web.Controls.Grid).DataItem("event_id").ToString

Record BeforeShow:

Grid, Record AfterExecuteSelect:


Artisteer Menu Format


Not sure if you already got this, but be careful of the menu builder. Below if how I got it done after contacting support. Underlying tone was I needed to read the directions better because this was in the directions and a departure from previous CCS technique....

You need to make an includable page (call it TOP), and it can ONLY contain links in list format, not the entire menu setup (Make the page TOP, go to HTML view and erase everything and start fresh there).

Top level will be in <li> tags, next levels are <li> tags within <ul> groups. The menu builder adds in extra classes and does not seem to work for me. To put the links in, I use the link button from FORMS>Controls. An example is below. In it, About Us will show on your menu when the page is opened. When you hover, it will expand the menu to show the 5 subtabs. This below is the only content seen in TOP, HTML view. The page properties has Includable property set to YES. The design page looks like a bunch of links with bullets.

<li><a href="{Link7_Src}" id="TOPLink7">About Us</a>
<li><a href="{Link8_Src}" id="TOP8">Why Saint Francis?</a>
<li><a href="{Link9_Src}" id="TOPLink9">Directions</a>
<li><a href="{Link10_Src}" id="TOPLink10">Employment</a>
<li><a href="{Link11_Src}" id="TOPLink11">Links</a>
<li><a href="{Link13_Src}" id="TOPLink13">Contact Us</a> </li>

Hope that helps. It is quite logical and seems a lot easier once you get the hand of it. I am liking CCS5 and Artisteer combo now that you can update/change Artisteer designs so easily in CCS5.



Setting FileFolder Property of FileUplod Control

This is a work around to setting the FileFolder property on the FileUpload component at runtime. It is specific to .Net InMotion and was done in CCS5.

I wanted to set the FileFolder property at runtime from an AppSettings value. The problem was setting it in the BeforeShow event of the control was too late in the page rendering process and I would get an error that the file couldn't be found when I edited a record. I also tried getting a reference to the control from a number of other page and record events but for some reason I could never get one back. As a work around I created a .dll in Visual Studio to grab the app setting value and put it in the bin folder of the website. Then, in the FileFolder property in CCS5 I entered the following:

<%# DRSLib.AppSettings.ExamFilesFolder %>

DRSLib is my .dll, AppSettings is my custom AppSettings class, and ExamFilesFolder is a shared/static read only property that returns the app setting value.

The reason I had to use a custom dll instead of just using the .Net AppSettings class is that using double quotes in this property causes problems.


Add User Control to Grid

  1. Create the User Control in Visual Studio.  In my example it was a simple DropDownList that had AutoPostBack set to True and redirected to another page on postback with a value from the grid.
  2. Register the control on the HTML page just after the Begin Panel Head.
  3. <%@ register tagprefix="uc1" tagname="MyUserControl" src="/dnn/Portals/9/my_user_control.ascx" %>
  4. Add the control in between table data tags (<td></td>).
  5. <td><uc1:MyUserControl id="StudentActionDL" runat="server" studentid='<%# Student.DataItem("StudentID") %>' examrequestaddpage="exam_request_form.aspx" /></td>

Student = the grid name

studentid = a public property in the user control.  You need to save the value to a hidden field if you need it on postback.

StudentID is one of the fields selected from the database.

examrequestaddpage is another public property of the control.




Adding Excel Export to a Report or Grid

  1. Add NPOI.dll and NPOIHelper.dll to the bin folder of the website.
  2. In the After Execute Select event of the report or grid add the following code:


  If Request.QueryString("Export") = "Excel" Then
   Dim SS As New NPOIHelper.Spreadsheet()
   SS.WebDownload(Response, "DownloadFilename")
  End If


Add an Export to Excel link to the page with an Expression parameter of Export=Excel.



RadioButtonList placing text before radio button

When creating a master page with Artisteer (Beta) for CCS 5.1 Release Preview, the radio button text is appearing before the radio button instead of after.  CCS support said to add float: left; to .art-radiobutton>input[type="radio"].  So I added the following to the CSS Export options:


   float: left;
   vertical-align: baseline;
   margin: 0 5px 0 0;


The same thing can be accomplished for a checkbox list.


    float: left;
    vertical-align: baseline;
    margin: 0 5px 0 0;


Their complete response:


Hello Craig,
I see the problem.
As workaround add the float:left to style.css file:

.art-radiobutton > input[type="radio"] {
float: left;

Also I would recommend that you upgrade CCS Export Plugin, the version 1.7 is available.

Best regards,

Helen Y.
Extensoft, Inc.
/ Artisteer
Artisteer - The Automated Web Designer

CCS Registry Keys

Sometimes after a CCS5 upgrade the app will have bugs or crash.  Yes recommends uninstalling the CCS, deleting the following registry entries, and reinstalling the app.  Be sure to turn off UAC, Windows Defender and are logged in as an Administrator.




In Windows 8



Using Menu Builder with Designs

I like using table (Data Source) generated menus in my CCS apps but they don't work when using Artisteer designs.  So I've come up with a workaround so the CCS menu builder control will display properly with Artisteer designs.  I'm using the ASP.Net VB InMotion templates and don't know if it will work with any other templates.  Also, my menu control was named Menu1.  If yours is name something else change it in the following steps.


1. Create an includable page and use the Menu Builder to create your menu.  In the menu builder wizard at the Style step, select Use styles from Design.


2. Switch to HTML view and comment out all of the generated script tags.  I add a "<!--" to the first line of the file and a "-->" just before <!--BEGIN Menu Menu1 --> (without quotes).


3. Add the following JavaScript after the comment but before the control starts.


<script src="/dnn/Portals/9/{page:pathToRoot}js/jquery/jquery.js" type="text/javascript"></script>
$().ready(function() {
        //Remove extra surrounding elements so db generated menu will work.
        //Remove the old responsive menu or you will get two responsive menus on devices (one of them empty).
        //Remove the extra "active" classes or else all of the menu items show as active.


4. Add the following HTML tag between <!-- BEGIN Menu Menu1 --> and <!-- BEGIN Item -->:

<ul class="art-hmenu">


5. Add the following HTML tag between <!-- END Item --> and <!-- END Menu Menu1 -->:




Below is the entire HTML file

<script language="JavaScript" type="text/javascript">
//Begin CCS script
//Include Common JSFunctions @1-65835CB2
<script src="/dnn/Portals/9/ClientI18N.aspx?file=globalize.js&amp;locale={res:CCS_LocaleID}" type="text/javascript" charset="windows-1252"></script>
<script type="text/javascript">
//End Include Common JSFunctions

//Include User Scripts @1-A6D16B54
<script src="/dnn/Portals/9/{page:pathToRoot}js/jquery/jquery.js" type="text/javascript"></script>
<script src="/dnn/Portals/9/{page:pathToRoot}js/jquery/event-manager.js" type="text/javascript"></script>
<script src="/dnn/Portals/9/{page:pathToRoot}js/jquery/selectors.js" type="text/javascript"></script>
<script src="/dnn/Portals/9/{page:pathToRoot}js/jquery/menu/ccs-menu.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="{page:pathToRoot}Styles/adx.css">
<link rel="stylesheet" type="text/css" href="{page:pathToRoot}Styles/None/Menu.css">
<script type="text/javascript">
//End Include User Scripts

//Common Script Start @1-8BFA436B
jQuery(function ($) {
    var features = { };
    var actions = { };
    var params = { };
//End Common Script Start

//Plugin Calls @1-157DF984
    $('*:ccsControl(main_menu, Menu1Container)').ccsBind(function() {
//End Plugin Calls

//Common Script End @1-562554DE
//End Common Script End

//End CCS script
<script src="/dnn/Portals/9/{page:pathToRoot}js/jquery/jquery.js" type="text/javascript"></script>
$().ready(function() {
        //Remove extra surrounding elements so db generated menu will work.
        //Remove the old responsive menu or you will get two responsive menus on devices (one of them empty).
        //Remove the extra "active" classes or else all of the menu items show as active.
<!-- BEGIN Menu Menu1 -->
<ul class="art-hmenu">
  <!-- BEGIN Item -->
  <!-- BEGIN OpenLevel -->
  <ul class="level{Menu1:Item_Level}">
    <!-- END OpenLevel -->
    <li><a href="{ItemLink_Src}" class="{Menu1:Submenu}" target="{Menu1:Target}" title="{Menu1:Title}">{ItemLink}</a>
    <!-- BEGIN CloseItem --></li>
 <!-- END CloseItem -->
    <!-- BEGIN CloseLevel -->
 <!-- END CloseLevel --><!-- END Item -->
<!-- END Menu Menu1 --></li>


Select All Checkbox Jquery

This jQuery script will allow a select all checkbox in the header to toggle the check boxes in an editable grid.  Rename NotifySelectAll to the toggle checkbox id and NotifyChk to the id of the check boxes in the grid.  Note: the jQuery select is looking for ID's that end with specified id.  So if there is something prefixed to the ID, it should still work.


    $(document).ready(function () {
        $("form input:checkbox[id$='NotifySelectAll']").change(function () {
            var $input = $(this);
            $("form input:checkbox[id$='NotifyChk']").prop("checked", $input.prop( "checked" ));