Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to Hide one element and show another
Message
 
Information générale
Forum:
ASP.NET
Catégorie:
Client-side développement
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01302771
Message ID:
01302814
Vues:
6
>>Hi everybody,
>>
>>Thanks to Paul I got the first part of my page working (or at least it seems to work in few tests I made).
>>
>>Now I'm up to the next "challenge".
>>
>>When I click on Edit button in my grid I show user's info in a separate table and hide the grid. I have Save button with server code and I have a Cancel button, which, I believe, should only hide the table and show the grid.
>>
>>So, I'm trying the following code in Page_Init (what better method should I use - this one fires too often)?
>>
>>
>>protected void Page_Init(object sender, EventArgs e)
>>    {
>>        this.btnCancelProfile.Attributes["onclick"] =
>>"HideElement('" +
>>this.tblProInfo.ClientID +
>>"');ShowElement('" + this.grdvwUsers.ClientID + "');" ;
>>    }
>>
>>However, the Hide part seems to be working, but the show part doesn't.
>>
>>Here is my code in Master.js file (which I added to Master page):
>>
>>
>>function HideElement(what)
>>{
>>alert(what);
>>var x = document.getElementById(what);
>>alert(x);
>>if (x) {
>>  x.style.display = 'none' ;
>>  }
>>  return true ;
>> }
>> function ShowElement(what)
>>{
>>alert(what);
>>var x = document.getElementById(what);
>>alert(x);
>>if (x) {
>>  x.style.visibility='visible'; ;
>>  }
>>  return true ;
>> }
>>
>>Do you see what is wrong?
>>
>>Thanks in advance.
>
>
>Change your function to this:
>
>function ShowElement(what)
>{
>alert(what);
>var x = document.getElementById(what);
>alert(x);
>if (x) {
>  x.style.display = '' ;
>  }
>  return true ;
> }
>
>
>There are two ways to hide and show an element.
>
>x.style.display = 'none' //hides element and releases the space it occupied
>x.style.display = '' //shows element
>
>and then there is:
>
>x.style.visibility = 'hidden' //hides element but does not release the space it occupies
>x.style.visibility = 'visible' //shows element

I'll try that tomorrow, but it looks like my problem lies somewhere else. The second alert was showing null though the ID seemed to be OK. Not sure why I can not retrieve it properly.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform