Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hiding and showing controls from the Client side
Message
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01306938
Message ID:
01306973
Views:
7
>Hi everybody,
>
>My mind is still going back to the problem I was trying to solve couple of days ago.
>
>I have a grid view on the form. When I press Edit button from this grid, I hide the grid (in server-side code) and then show information in the table where I have 2 buttons Save and Cancel.
>
>Here is some relevant info in the Edit code:
>
>
>this.drpSelRole.Visible = false;
>        this.grdvwUsers.Visible = false;
>        this.tblProInfo.Visible = true;
>
>This is from the Save button's code:
>
>
> this.lblProfStat.Text = "Profile Saved";
>        this.lblProfStat.Visible = true;
>        this.drpSelRole.Visible = true;
>        this.grdvwUsers.Visible = true;
>        this.tblProInfo.Visible = false;
>
>Putting similar code in the Cancel button also works fine.
>
>However, it sounds like such a waste to do it on the server-side.
>
>Here are my attempts to do it Client-side:
>
>
>protected void Page_Init(object sender, EventArgs e)
>    {
>        //this.btnCancelProfile.Attributes["onclick"] = "HideElement('" + this.tblProInfo.ClientID + "');" ;
>        this.btnCancelProfile.Attributes["onclick"] = "ToggleDisplay('true','GridInfo','" +
>            this.drpSelRole.ClientID + "','" + this.grdvwUsers.ClientID +
>            "');ToggleDisplay('false','ProfileInfo');return false;";
>
>
>        this.btnAddToRole.Attributes["onclick"] = "return CheckSelected('" + this.lsbUsers.ClientID +
>                                                 "','Please select Users') && CheckSelected('" +
>                                                 this.LsbRoles.ClientID + "','Please select Roles');";
>
>Unfortunately, only "hiding" part works for this button and the grid and combobox never re-displayed.
>
>Do you know what may be wrong and why I can not make them re-appear using Client-side code?
>
>Thanks in advance.

Ok, I answered my own question as to why it was not working. Since I was setting visible property, the controls were not rendered in the resulting page.

So, by someone's here suggestion I changed this to
 this.drpSelRole.Style.Add("Display", "none");

       // this.drpSelRole.Visible = false;

       // this.grdvwUsers.Visible = false;
        this.grdvwUsers.Style.Add("Display", "none");
and now Cancel button works, but Save doesn't :)

Anyway, getting there, I believe.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform