Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Affordable ASP.NET Hosting Service
  Ads  
 


  Sponsors  

Meet Our Sponsors

telerik
ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  LinkButton Generated In Code Behind
Previous Previous
 
Next Next
New Post 4/1/2008 8:34 AM
User is offline Rick
9 posts
10th Ranked


LinkButton Generated In Code Behind 

I am attempting to add asp linkbutton controls to a DNN module I am creating.  The linkbutton appears as simple text with no 'button' functionality.  I added an asp linkbutton control in the designer and it converted to

<a id="dnn_ctr375_ViewOIG_AppMgr_LinkButton1" href=" __doPostBack('dnn$ctr375$ViewOIG_AppMgr$LinkButton1','')">LinkButton</a>

from

<asp:LinkButton ID="LinkButton1" runat="server" OnCommand="cmdLink">LinkButton  </asp:LinkButton>

When I view the source code for the page, the asp:linkbutton I added in the code (Page_Load) is properly formatted and should work.  Obviously there is something that I am missing and am unfamiliar with as it relates to DNN.  What do I need to do to add linkbuttons from within the Page_Load?

Thanks in advance for your help.

 

 

 
New Post 4/1/2008 12:52 PM
User is offline Nathan Rover
39 posts
www.websitemakers.com
10th Ranked


Re: LinkButton Generated In Code Behind 

Rick,

I’m not too sure what you’re trying to do, but it is possible to add a link button in the Page_Load and have it fire off a command.

In my VB file I have this code:

Dim lb As LinkButton

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load

     lb = New LinkButton

     lb.ID = "LinkButton1"

     lb.Text = "LinkButton"

     AddHandler lb.Command, AddressOf cmdLink

     putlb.Rows(0).Cells(0).Controls.Add(lb) 'Puts lb on page...

End Sub

 

Public Sub cmdLink(ByVal sender As Object, ByVal e As CommandEventArgs)

     'Do something

End Sub

In my ASCX file I have this code:

<table id="putlb" runat="server">

    <tr>

        <td>


        </td>

    </tr>

</table>  

If you can help it, stay away from doing this… It’s possible but it’s usually not worth the headaches. If you do have to go this route get real familiar with the page load life cycle.

-- Nathan Rover

 
New Post 4/1/2008 12:52 PM
User is offline Steve Fabian
1516 posts
5th Ranked








Re: LinkButton Generated In Code Behind 
Modified By Steve Fabian  on 4/1/2008 2:53:40 PM)

Hey Rick,
Here's the code I use in the Repository module to create a LinkButton in the code behind and add it to a placeholder control on my user control

 Dim lbBtn As New LinkButton
lbBtn.ID = "lbMyID"
lbBtn.CommandName = "MyCommandName"
lbBtn.CommandArgument = "MyCommandArgument"
lbBtn.Text = "My Button Text"
lbBtn.CssClass = "MyButtonClass"
ctlPlaceHolder.Controls.Add(lbBtn)
AddHandler lbBtn.Click, AddressOf Me.LinkButtonHandler

 

Hopefully that will help y ou out. Obviously, all of the value names would be changed for your module. The key is to have a LinkButtonHandler function defined in your module to catch and process link button commands, then add a handler to your dynamic link button and hook it up to your handler function.


Steve Fabian
Gooddogs.com
Sit, Stay, Code ... Good boy!
 
New Post 4/1/2008 1:54 PM
User is offline Rick
9 posts
10th Ranked


Re: LinkButton Generated In Code Behind 

Things are definitely looking up.  Thank you both for your advice.  The only remaining issue is that the cmdLink subroutine doesn't seem to fire.  I have added the

AddHandler

lb.Command, AddressOf Me.cmdLink

statement.  When I set a breakpoint in cmdLink, execute the module, and select one of the beautifully formatted linkbuttons ... nothing.  What 'goatchas' may I be missing with the handler?

 
New Post 4/1/2008 2:44 PM
User is offline Rick
9 posts
10th Ranked


Re: LinkButton Generated In Code Behind 

Ahhh ... I changed the handler from a Command handler to a Click handler and everything is working as I want it to now. 

Thank you very, very much for the help!

 

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  LinkButton Generated In Code Behind
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Glanton: Enterprise Intranet Specialists Using DNN
Glanton Solutions are a premier provider of sevices for large corporates lloking to outsource Intranet sites.
www.glanton.com
Jetkey Smart Map
Smart Map is an AJAX powered Google Map module that displays driving directions, proximity search results and data from your own databases. Smart Map reads GPX (GPS data) files, GeoRSS feeds, and KML data. You can pass any querystring parameter to Smart Map and into your own custom queries to control what data displays on the map.
smartmap.jetkey.com
DNNSpired.com
Inspired to extend DotNetNuke®, everyday.
www.DNNSpired.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP