|
-
Aug 24th, 2004, 01:16 AM
#1
Thread Starter
Fanatic Member
CallByName multiple property levels?
I want to add attributes to 24 textboxes but am not sure how to go about it.
I have
Code:
for i = 1 to 24
CallByName("textbox"+i,"attributes.add",CallType.Method,"'onclick','CheckTxtBox(this)'")
next i
And it throws up on this saying
Exception Details: System.MissingMemberException: Public member 'Attributes.Add' on type 'String' not found.
[MissingMemberException: Public member 'Attributes.Add' on type 'String' not found.]
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) +883
Microsoft.VisualBasic.Interaction.CallByName(Object ObjectRef, String ProcName, CallType UseCallType, Object[] Args) +48
imac.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Jared\VSWebCache\index.aspx.vb:109
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
I'm pretty sure it doesn't want me putting in more than just attributes but I need to access the add.... Help would be appriciated.
Last edited by Graff; Aug 24th, 2004 at 01:22 AM.
If wishes were fishes we'd all cast nets.
-
Aug 24th, 2004, 06:16 AM
#2
PowerPoster
Hi,
I take it you have used
Inherits System.Attribute
??
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Aug 24th, 2004, 10:43 AM
#3
Thread Starter
Fanatic Member
mmmm not sure......
I guess I should mention this is a ASP.NET project with VB.NET code behind and I probably should have posted this on the ASP forum....
Basically I have a webform with 24 textboxes (for simplicity sake called TextBox1 to 24)
I'm trying to add some javascript functions that are triggered by the onclick and onkeyup events. Right now I have
[Highlight=VB]Textbox1.Attributes.Add("OnClick","SetActive(this)")
TextBox2.Attributes.Add("OnClick","SetActive(this)")
.
.
.
TextBox24.Attributes.Add("OnClick","SetActive(this)")
TextBox1.Attributes.Add("OnKeyUp","CheckMsg(this)")
TextBox2.Attributes.Add("OnKeyUp","CheckMsg(this)")
.
.
.
TextBox24.Attributes.Add("OnKeyUp","CheckMsg(this)")[/vbode]
I'd like to just have
VB Code:
For i = 1 to 24
TextBox+i.Attributes.Add("OnClick","SetActive(this)")
TextBox+i.Attributes.Add("OnKeyUp","CheckMsg(this)")
next
Only way I know of accomplishing that is using the CallByName function but I'm not quite sure how to use it when you have multiple levels to the method you're trying to invoke
If wishes were fishes we'd all cast nets.
-
Aug 25th, 2004, 01:43 AM
#4
VB Code:
For Each ctrl As Control In Page.Controls
If TypeOf (ctrl) Is TextBox Then
Dim tb As TextBox = CType(ctrl, TextBox)
tb.Attributes.Add("'onclick'", "'CheckTxtBox(this)'")
End If
Next
Note: this will do every textbox on the form, you will have to setup an if statement if you want to limit what textboxes get new attributes.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|