473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 5175
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.