Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 31st, 2005, 05:39 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #2 (permalink)  
Old February 1st, 2005, 06:38 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
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.
  #3 (permalink)  
Old February 2nd, 2005, 12:42 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
  #4 (permalink)  
Old February 3rd, 2005, 06:23 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
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.
  #5 (permalink)  
Old February 3rd, 2005, 12:09 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.