Link to home
Create AccountLog in
Avatar of misdevelopers
misdevelopers

asked on

How to create a LinkButtonTester object in NUnitAsp

How do I create a New LinkButtonTester using NUnitAsp for a LinkButton that is nested inside a DataGrid which is also inside an update panel which is also inside a ContentPlaceHolder?  

I cannot find the correct name to use so that NUnitAsp can find it on my page.
Avatar of Merete
Merete
Flag of Australia image

Hi misdevelopers, well done
can this assist you as a starting point as I am no epert in this area really.
This guide contains a brief description of NUnitAsp and how to use it. It assumes that you're familiar with NUnit, ASP.NET, and unit testing
Quick start guide
http://nunitasp.sourceforge.net/quickstart.html
Overview
http://nunitasp.sourceforge.net/
Using NUnitASP to test DataGrid editing
http://www.cornetdesign.com/2005/07/using-nunitasp-to-test-datagrid.html

Good Luck
Avatar of misdevelopers
misdevelopers

ASKER

Thanks!  Prior to posting my question here I had reviewed the sites you've mentioned.

In the examples, they give a name in the parameter for the name of the LinkButton, as follows:

LinkButtonTester updateLink = new LinkButtonTester("cmdUpdateReasonCode", editRow);

I create my asp datagrid control with an asp:ButtonColumn using the following code:

<asp:ButtonColumn CommandName="SelectClass" Text="Select Class"></asp:ButtonColumn>

There is no ID for this linkbutton that I can find to reference in the above parameter.  (SelectClass or Select Class doesn't work, I tried).
ASKER CERTIFIED SOLUTION
Avatar of Merete
Merete
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Well, that last link you found helped me solve the problem.  The problem was the way I was creating the linkbutton in the ASP.Net datagrid.

Solution:
Instead of:
     <asp:ButtonColumn CommandName="SelectClass" Text="Select Class"></asp:ButtonColumn>

You need to use:
     <asp:TemplateColumn>
           <ItemTemplate>
                <asp:LinkButton ID="ViewClasses" Text="View Classes" runat="server" CausesValidation="false" CommandName="ViewClasses"></asp:LinkButton>
            </ItemTemplate>
      </asp:TemplateColumn>

This gives the required Id to work with.

Thanks!
oh my god  that's awsome for you and makes very happy.
Cool. Thank you
Best Wishes
Merete