• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

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
0
tybarton
Asked:
tybarton
  • 6
  • 3
1 Solution
 
tybartonAuthor Commented:
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
0
 
CodeCruiserCommented:
0
 
tybartonAuthor Commented:
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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CodeCruiserCommented:
>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?
0
 
tybartonAuthor Commented:
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
0
 
CodeCruiserCommented:
If you want them to be rendered but not visible, set the Style attribute to "Display:None"
0
 
tybartonAuthor Commented:
I'll have to try that on Monday when I get to work.

Thanks,
Ty
0
 
tybartonAuthor Commented:
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
0
 
tybartonAuthor Commented:
Half of the questions was answered. I figured out the rest.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now