Santry Technology Solutions, Content Management, DotNetNuke, SharePoint Consulting
Register | Login
Tuesday, December 02, 2008

Sections
  
About Us
  
Partners
Downloads
  
 WWWCoder.com Resource Directory

 

ORDER TODAY!
Professional DotNetNuke ASP.NET Portals
Amazon.com now has the only DotNetNuke book you'll ever need. Written by the guys who brought you DotNetNuke, Shaun Walker, Patrick Santry, Joe Brinkman, Dan Caron, Scott McCulloch, Scott Willhite, and Bruce Hopkins. Order it now! .

DotNetNuke - Open a module in a new window or Redirect
12/29/2006 9:07:24 AM

When developing custom modules sometimes you will want to either open a window or redirect the user to another module that you have for say a detail page.

When developing custom modules sometimes you will want to either open a window or redirect the user to another module that you have for say a detail page.

I have seen many methods on the Internet with javascript etc...This will show you how to do it with out the use of javascript.

Controls Setup:
1. You have your view, edit, settings and one more "view" control called "ShowEvents" which is going to show a list of all events.
2. You are on your development machine working with dotnetnuke and your module.
3. In the viewMyEvents control you have a datalist and is bound to a datasource

Page Code:

'As you can see in the page code that you will be returning all the events for a given portal and event moduleid.

<ul>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
SelectCommand="SELECT DISTINCT [EventName], [EventID] FROM [Events] WHERE (([ModuleID] = @ModuleID) AND ([PortalID] = @PortalID))">
<SelectParameters>
<asp:QueryStringParameter Name="ModuleID" QueryStringField="tabid" Type="Int32" />
<asp:QueryStringParameter Name="PortalID" QueryStringField="portalid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:datalist id="lstContent" datakeyfield="EventID" runat="server" cellpadding="4" DataSourceID="SqlDataSource1">
<itemtemplate>

<li>
<asp:Label ID="EventIDLabel" runat="server" Text='<%# Eval("EventID") %>'></asp:Label>
<asp:Label ID="EventNameLabel" runat="server" Text='<%# Eval("EventName") %>'></asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server" Target="_blank" >LinkButton</asp:HyperLink>
</li>

</itemtemplate>
</asp:datalist>


In the ItemDataBound Event:

1. Open Page in new window:

'Remember that we want the user to click on one of the
' events and get a new window with all the details in
' the ShowEvents "view" .ascx control. We pass the
' event id in the url so that ShowEvents can display
' the correct event

'As you can see I am using the Attributes.Item("href")
'instead of the NavigateUrl attribute becuase when it is
'rendered to the brower I want it to work.

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then

Dim lnk1 As HyperLink = CType(e.Item.FindControl("HyperLink1"), HyperLink)
lnk1.Attributes.Item("href") = NavigateURL(TabId, "ShowEvents", "mid=" & ModuleId.ToString & CType(e.Item.FindControl("EventID"), Label).Text)

End If

2. Redirect to another page:

'Add a linkbutton to your datalist
'in the itemcommand you will get the eventid and pass
' it along with the redirect:

Protected Sub lstContent_ItemCommand(ByVal source As Object, ByVal e As _
System.Web.UI.WebControls.DataListCommandEventArgs) Handles _
lstContent.ItemCommand

Response.Redirect(NavigateURL(TabId, "ShowEvents", "mid=" & _
ModuleId.ToString & "&eventid=" & CType(e.Item.FindControl("EventIDLabel"), _
Label).Text))

End Sub


Charles Stratton has been programming since 1999 and enjoys staying on the edge of technology. his skills range from DNN to Sharepoint to Custom Development. currently working in VB.Net and C#.Net web and software. KISS - Programmers work smarter not harder. Charles can be reached at stratcr@peoplepc.com.

     


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
Left on 8/5/2008 2:05:40 PM by Anonymous
Comments: I'm having a problem using this technique. The contents of the control (the one you redirect to) is not aligned to the left.
No ratings available.
Left on 7/17/2007 5:19:19 AM by Anonymous
Comments: the same should be submited for asp.net also......
Left on 3/19/2007 12:03:25 PM by Anonymous
Comments: I wish there is some download sample code. It's rather vague for newbie like me.
Left on 1/11/2007 11:55:37 AM by Anonymous
Comments:
  

 Latest Articles
  

 Latest News
  

 

Spotlight
Syndication

 


 


Digg This
 


DotNetNuke Platinum Benefactor

  
 

 Terms Of Use | Privacy Statement
 Copyright 2008 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970