Link to home
Create AccountLog in
Avatar of 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
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
Using NUnitASP to test DataGrid editing

Good Luck
Avatar of misdevelopers


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).
Avatar of Merete
Flag of Australia image

Link to home
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.

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

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

This gives the required Id to work with.

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