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

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Converting a Simple ASP.NET Page to DNNConverting a Simple ASP.NET Page to DNN
Previous
 
Next
New Post
2/17/2008 8:41 PM
 

I am having a problem converting a simple ASP.NET site to a DotNetNuke site.

 

On my ASP.NET site I have a form with a text box, 4 drop down boxes and a submit button. When submitted it then builds a query string and opens another page. The next page accesses a database and displays the results in a gridview.

 

I want to do the same thing in DNN.

 

I have created 2 modules: one with the original form (submit button) and one for the results (gridview).

 

Problem:

            I cannot consistently navigate to the results tab (page). It seems like I can navigate to it after the page has been loaded for more than 30 seconds but before that it just reloads the page and clears the form.

 

Here is my code for the button:

protected void btSubmit_Click(object sender, EventArgs e)

{

string sKey1 = "", sKey2 = "";

sKey1 = "Key1=" + ddlKey1.SelectedValue;

sKey2 = "Key2=" + ddlKey2.SelectedValue;

sItemName = "ItemName=" + tbItemName.Text;

string[] aString = new string[] { "322", sKey1, sKey2, sItemName };

HttpContext.Current.Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(73, "", aString), true);

return;

}

 

A few notes:

* I am completely new to DNN.

* I found out after doing more research that I could have probably used one module for this but I am more interested in figuring this out then changing the module at this point.

* I removed the form tag from the original form.

* I changed default cache time to 0 on the submit module.

* I know I can make the page more dynamic but I am just trying to do a proof of concept.

* I used http://www.adefwebserver.com/DotNetNukeHELP/NavigateURL/ as a reference.

* If I use “mid=322” in my string array the correct tab (page) does not display.

 
New Post
2/18/2008 1:25 PM
 

You can easily do this by using an ASCX page in your application instead of an ASPX page.

Add "Imports DotNetNuke" to the code behind, and add a reference to your "DotNetNuke.dll" file and set the atttributes to not copy local

modify the inherits code to reflect the change:
"Inherits DotNetNuke.Entities.Modules.PortalModuleBase"

You should be able to then code against the DNN framework and use the ASCX page as module.

 
New Post
2/18/2008 2:11 PM
 

Justin – Thank you for your reply.

I also wanted to state that I didn’t mean to sound so impersonal in my original post. I am just so frustrated by this. I have tried about 10 different ways and I cannot find a way to do it. Any help is really appreciated.

My problem is not that I cannot make this into a module. What I can’t do is replicate the functionality on my original site in DNN. It could possibly be that I am thinking about this the wrong way, from an ASP.NET perspective instead of a DNN one.

My problem is that I cannot pass parameters from one page to another. It seems that there is not a set way to do this. One post even made me think that this is not really possible. Is it possible and how is it done?

Thank you,

John

 
New Post
2/18/2008 3:21 PM
 

I think one of the things confusing you is the terminology.. you shouldn't confuse 'modules' with 'pages'. A module is a set of functionality, and in most cases is represented by a single page (ascx file). However, a module can also be many, many pages (ascx files). 

Here's how you should go about structuring your module.

/DesktopModules/YourModule
    MyQueryForm.ascx
    MyResultsForm.ascx
    YourModule.dnn
    ...

One module, two pages. Now in your manifest file that is used to 'install' your module, you specify the 'controls'. Now if you relate 'controls' to 'pages' you'll be fine. So based on your module, you need to define 2 'controls'. One control for the page where you enter your query, and one control where you display the results.

In the 'controls' section of the .dnn file ( or you can always just enter the control information manually on the Host->Module Definitions page.) add the two controls.

...
<control>
  <src>DesktopModules/YourModule/MyQueryForm.ascx</src>
  <type>View</type>
</control>
<control>
  <key>Results</key>
  <title>My Query Results</title>
  <src>DesktopModules/YourModule/MyResultsForm.ascx</src>
  <type>View</type>
</control>
...

So, now, when you drop an instance of your module on the page, the MyQueryForm.ascx page will automatically be displayed since it does not have a key it becomes the default 'view'. 

When your user fills out the form and clicks on the submit button, you would execute the following code in the click handler for your button.

' MyQueryForm.ascx
' submitButton_Click handler
...
Dim params() as string
params(0) = "sKey1=''"
params(1) = "sKey2=''
params(2) = "Key1=" & ddlKey1.SelectedValue.ToString()
params(3) = "Key2=" & ddlKey2.SelectedValue.ToString()
params(4) = "sItemName=" & tbItemName.Text
Response.Redirect = EditUrl("", "", "Results", params)

That code will look for the control with a key equal to "Results" and load the page associated with that key into your module, so the 'MyResultsForm.ascx' which is associated with the "Results" key will be loaded into your module and displayed to the user. Your parameters are passed from one page to another through the parameters string array, which is a string array of name=value pairs.  In the MyResultsForm.ascx file, you access the parameters through the querystring collection

' MyResultsForm.ascx.
Dim sItemName as string = Request.QueryString("sItemName")

Once you get the relationship between your .ascx files and the controls collection for a module, using the EditURL is a great way to move from page to page within your module and to also pass data between them

When the MyResultsForm.ascx control is displaying the data to the user, you can have a hyperlink or button that allows them to return to the Query form

' returnButton_Click handler
Response.Redirect(NavigateURL())


Since you don't need to pass data back to the Query Form, just use NavigateURL() to load your module with the default control, MyQueryForm.ascx.

 
New Post
2/18/2008 3:58 PM
 

Steve - That makes sense. I will give it a try. Also, your post helped shed some light on Justin's post.

For the record, I am not a coder by trade. I picked it up along the way with no formal training and I brute force my way through a lot of things so I appreciate both of you taking the time to help me.

John

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Converting a Simple ASP.NET Page to DNNConverting a Simple ASP.NET Page to DNN


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