|
-
Feb 14th, 2013, 02:31 AM
#1
Thread Starter
PowerPoster
[RESOLVED] How to reference a <div> element using code-behind?
I have a <div> element in a web page. I've assigned it an "ID" and made it a server-side control by using "runat=server". How do I define that <div> in the code-behind. I'm been looking at the "System.Web.UI.HtmlControls" namespace and not sure what to use. The reason I need to do this is because within this <div> is a "Submit" button which will cause a postback. When I click the submit button the first thing it does is it executes a procedure to perform edit checks on the various textbox controls. If a control is empty, a message pops up. When the user clicks "Ok" for the message, the <div> disappears because when the form loads, the <div> style.display property is set to "none" by default.
Maybe there is a better way to control this. Basically, all I want is for the <div> not to disappear when the edit checks are performed and a messagebox pops up. Any ideas?
Thanks,
-
Feb 14th, 2013, 07:31 PM
#2
Re: How to reference a <div> element using code-behind?
-
Feb 14th, 2013, 07:59 PM
#3
Thread Starter
PowerPoster
Re: How to reference a <div> element using code-behind?
-
Feb 15th, 2013, 01:58 PM
#4
Re: How to reference a <div> element using code-behind?
I believe using a HtmlGenericControl should allow you to access the div.
-
Feb 15th, 2013, 03:19 PM
#5
Thread Starter
PowerPoster
Re: How to reference a <div> element using code-behind?
Thanks kfcSmitty...I'll give it a shot!
-
Feb 15th, 2013, 05:53 PM
#6
Re: How to reference a <div> element using code-behind?
Hello Blake,
You would only need to do this if you were creating the control on the server side, and then injecting it into the page.
The fact that you have added the runat=server means that you can reference the already created instance of that div element on the server side.
Gary
-
Feb 15th, 2013, 06:08 PM
#7
Thread Starter
PowerPoster
Re: How to reference a <div> element using code-behind?
That Gary...I made some changes and got it working!
-
Feb 19th, 2013, 02:41 AM
#8
Re: [RESOLVED] How to reference a <div> element using code-behind?
Hey,
Out of interest, what were the changes?
Gary
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
|