Avatar of tybarton
tybarton

asked on 

Dealing with manually created control in ASP.net/VB.net

I am manually creating buttons on my web page in my code behind load event. The buttons are to be tied with some manually created textboxes.

I want the textboxes to be invisible unless the user clicks the button associated with the textbox.

1. Not sure how to call the click events of the buttons. There are many buttons. I guess a generic click handler evaluating the ID if the button.

2.How to set the textbox visible when I do not know the full name of the control since they are dynamically created.

Any help is appreciated.

Tyler
ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
tybarton
Avatar of tybarton
tybarton

ASKER

Ok I think I found a solution for the first part. Sorta....maybe.
The buttons have a onclientclick so I created a function for the click and point the onclientclick to that function.

dim lnkbtn as new linkbutton
lnkbtn.id = "Test"
lnkbtn.onclientclick = buttonclickevent(lnkbtn.id)

Protected Function ButtonClickEvent(byval strid as string) as boolean

End Function

It sorta works. When I render the page and click on the button I first get a error in the dynamic page. It looks like when I use this event ASP.net adds a OnClick = "false" to the button. If I hit continue the function does run however I'm worried that the page will choke in production.

Still not sure about number 2.

Thanks,

Tyler
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of tybarton
tybarton

ASKER

Actually I beleive they would because the are actually rendered on the page just not visible. The issue is this page is a massive table with lots of cells and controls 98% completed and all manually created in the code behind due to a large number of sql queries that need to be ran to get data for the controls. So a redesign is not in my future.

Thanks,

Ty
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

>Actually I beleive they would because the are actually rendered on the page just not visible.

Have you checked the html in the browser? Can you show screenshot of the page?
Avatar of tybarton
tybarton

ASKER

I stand corrected. They are not there which is odd cause I could swear that I did this before. I'll have to look for the code. Maybe I kept the controls visible in the code behind then changed the visibility in jscript not sure.

Thanks,

Ty
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of tybarton
tybarton

ASKER

I'll have to try that on Monday when I get to work.

Thanks,
Ty
Avatar of tybarton
tybarton

ASKER

That worked great. I also figured out how to deal with the dynamic buttons. I am going to give you half credit for your part of the answer.

Thanks,

Tyler
Avatar of tybarton
tybarton

ASKER

Half of the questions was answered. I figured out the rest.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo