Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2005, 05:39 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Show web user control hidden

Hello:
I have a web form, which contains 2 web user controls embedded in it.
First web user control contains a button, which when be pressed I need 2nd web user control be showed (this 2º web user control has property visible = false).
I don’t found the way to attain when user push button in 1st. web user control, property visible of 2nd web user control be place to true, and thus it be showed.
I’ll thank you in advance if you’ll be able to help me.
A.L.


El Hombre que tiene Amigos ha de mostrarse Amigo
__________________
El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old February 1st, 2005, 06:38 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think you finally need to add an event to your usercontrol,so in your ascx file you should make an event and also accordingly a protected method for raising that event,
Code:
public event EventHandler UserControlClick;
protected void OnUserControlClick(EventArgs e)
{
      if(UserControlClick != null)
      {
         UserControlClick(this, e);
      }
}
then in Button1_Click you execute that protected method(for rasing the event),
Code:
private void Button1_Click(object sender, System.EventArgs e)
{ 
      OnUserControlClick(e); 
}
then in your ASP.NET page you put your usercontrols and also attach your new delegate to the event,
Code:
//code-behind for your ASP.NET page
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load);
UserControl1.UserControlClick +=new EventHandler(WebForm1_UserControlClick);
}
private void WebForm1_UserControlClick(object sender, EventArgs e)
{
  //set the visible property of the UserControl2 to true       
}
HtH.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old February 2nd, 2005, 12:42 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you Mehdi:
Your solution is using totally C# and work fine.
There are another way to do,I share it:
The web user control to show is inside a panel, visibility of panel can change as I do trough JavaScript functions.

function esconde()
{
document.getElementById('Panel1').style.visibility = "hidden";
 }
function muestraX()
{
     document.getElementById('Panel1').style.visibility = "visible";
}

I hope this be useful.

A.L.



El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old February 3rd, 2005, 06:23 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

your solution works on the client-side,however I don't know where you added those javascript functions,anyway it's better for usercontrols to be reusable in different situations.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old February 3rd, 2005, 12:09 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When user push button in web user control I send to execute a code contained in a button hide in web form in which I have this code:
string leyenda = "<script languaje = javascript>esconde();</script>";
if(!this.IsStartupScriptRegistered("Pb"))
{
    Page.RegisterStartupScript("Pb",leyenda);
}
And esconde() is JavaScript function I'm using.
A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hidden VBA module....How can I get it to show? Ben Horne Access 3 May 4th, 2007 06:43 PM
How to show a button have hidden property ??? nobitavn94 ASP.NET 1.0 and 1.1 Basics 2 November 19th, 2006 09:39 AM
Add Windows User control in Web User Control agarwalvidhu C# 0 March 30th, 2006 01:17 AM
Web user control EvilGuyWhoEatsBrains General .NET 1 December 14th, 2004 01:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.