472,993 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

setting html control property in javascript and page behind code

Hi,
I have a div control on an aspx page. I toggle the display property between
'block' and 'none' client side using the following javascript:

function toggleDivOnOff(divID) {
var x = document.getElementById(divID)
x.style.display == 'block'? x.style.display='none' : x.style.display='block';
}

In the code behind page, I want to use the value of the display property to
decide on an action to be taken using the following:

if (mydiv.Attributes.CssStyle["display"] == "block")
{
//do something
}

However, it would seem that although I can alter the way the div is
displayed on the aspx page either via the javascript or using code behind (
e.g. mydiv.Attributes.CssStyle["display"] = "block";), the code behind seems
not to recognise changes made in the javascript . Is there a way of
referencing the display property in the code behind in such a way as to avoid
this problem?

Many thanks,

Pete
Dec 28 '05 #1
2 5163
pH
The properties of the DIV as set on the client side will not
automatically be sent back to the server by the ASP.NET page, as only
input fields (and viewstate) are sent, not properties of other objects
on the page.

I would probably store the visibility in a hidden INPUT field on your
form (perhaps neatest to do this in your FORM onsubmit event, if you
set the visibility from more than one location), and this can then be
checked from server-side code.

Dec 28 '05 #2
many thanks pH. Your explanation isvery clear.

"pH" wrote:
The properties of the DIV as set on the client side will not
automatically be sent back to the server by the ASP.NET page, as only
input fields (and viewstate) are sent, not properties of other objects
on the page.

I would probably store the visibility in a hidden INPUT field on your
form (perhaps neatest to do this in your FORM onsubmit event, if you
set the visibility from more than one location), and this can then be
checked from server-side code.

Dec 28 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Amir Eshterayeh | last post by:
Dear Friends Hope things goes well to you. I have this problem. Would you please give me your solution? I want to change a property that I define on my user control in my web form that contains...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
1
by: Gramps | last post by:
Hi, I have a simple ascx(Banner) that consists of an image a label and a public property, 'ThisTitle'. From a page I want to set the label via assignment to the property. The only way I can...
4
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where...
6
by: Andre Ranieri | last post by:
I'm trying to create a login page for customers to log into our corporate website, our presidents naturally wants the user and password fields to populate from a cookie so the customer doesn't have...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
3
by: Mark Rae | last post by:
Hi, Just a general quickie on setting properties of user controls from the parent form. Let's say I have a user control called note.ascx which displays a datagrid. That datagrid is populated...
6
by: WT | last post by:
Hello, I am searching for a way to generate automatically from codebehind the <!Doctype....for asp.net pages using .net 3.5 c# and vs2008. Subidiary question: if I do a server transfert in my...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.