Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 13th, 2006, 03:45 AM
Authorized User
 
Join Date: Jan 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default class file

The below line set the text in the textbox inside the gridview

((TextBox)DtClass.FindMyControl(GridView,"TextBox1 ")).Text="hi";

Below is the code for finding the id of a control and doing an action with it,say finnding the textbox id inside a grid.


public static Control FindMyControl(Control c, string s)
        {
            Control found = null;

            for(int i = 0; i < c.Controls.Count; i++)
            {
                if(c.Controls[i].UniqueID.EndsWith(s)==true)
                {
                    found = c.Controls[i];
                    break;
                }
                else
                {
                    found = FindMyControl(c.Controls[i], s);
                    if(found != null)
                        break;
                }
            }
            return found;
        }

how do you convert the same code in vb.net.i did convert , but i am getting error of object reference not set to an instance of an object.
below is my vb code.

 Public Shared Function FindMyControl(ByVal c As Control, ByVal s As String) As Control
        Dim found As Control = Nothing
        Dim i As Integer = 0
        Do While (i < c.Controls.Count)
            If (c.Controls(i).UniqueID.EndsWith(s) = True) Then
                found = c.Controls(i)
                'TODO: Warning!!! break;If

            Else
                found = FindMyControl(c.Controls(i), s)
                If (Not (found) Is Nothing) Then
                    'TODO: Warning!!! break;If
                    GoTo p


                End If

            End If
            i = (i + 1)
        Loop
p:
        Return found
    End Function

Hope this is the right one.(Please tell me if any error is there above.im new to vb.net)

 CType(DtClass.FindMyControl(GridView1, "TextBox1"), TextBox).Text="hi"

while running the code im getting error object reference not sat to an instance of an object.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Class within ASPX file kingroon ASP.NET 2.0 Basics 3 July 9th, 2008 07:43 AM
Class File Asp_Developer Visual Basic 2005 Basics 1 April 30th, 2008 10:56 PM
Class file SKhna Ajax 1 February 4th, 2008 11:30 AM
Regarding Class Library (.dll) from class file manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 March 3rd, 2006 07:32 AM
class file server sivapmk J2EE 3 December 14th, 2003 08:02 AM



All times are GMT -4. The time now is 12:40 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.