-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Mrinal
Message 3 in Discussion

Hi Bhavtosh ,   I am able to make some headway into the problem , however i don't 
suggest this to be an ideal solution as it is more a turnaround to get the things done 
, what i have done is :   Created a UserControl having a button say btnFirst and 
another user control with btnSecond , now i have set a couple of public properties 
that can serve my logic by setting some bool values which can be checked and necessary 
logic can be executed ,   For E.g: My UserControl1 having btnFirst is as follows :   
***************************************** First User Control 
************************************************************  
namespace UserControlTry 
{ 
using System; 
using System.Data; 
using System.Drawing; 
using System.Web; 
using System.Web.UI.WebControls; 
using System.Web.UI.HtmlControls;  
public abstract class FirstButton : System.Web.UI.UserControl 
{ 
protected System.Web.UI.WebControls.Button btnFirst; 
protected bool hasClicked; 
private void Page_Load(object sender, System.EventArgs e) 
{ 
} 
public void btnFirst_Click(object sender, System.EventArgs e) 
{ 
hasClicked = true; 
Session["boolVal"] = hasClicked; 
} 
public bool HasClicked 
{ 
get 
{ 
hasClicked = (bool)Session["boolVal"]; 
return hasClicked; 
} 
} 
} 
} 
Now crazy thing out here is button click event is public because as u will see the 
code in main webpage , it need to call this event from there , otherwise it leads to 
another peculiar problem . 
*************************************** Second User Control Code is As Follows 
************************************************************** 
namespace UserControlTry 
{ 
using System; 
using System.Data; 
using System.Drawing; 
using System.Web; 
using System.Web.UI.WebControls; 
using System.Web.UI.HtmlControls; 
public abstract class SecondButton : System.Web.UI.UserControl 
{ 
protected System.Web.UI.WebControls.Button btnSecond; 
protected bool checkVisibility; 
private void Page_Load(object sender, System.EventArgs e) 
{ 
} 
public bool setVisibility 
{ 
get 
{ 
return checkVisibility; 
} 
set 
{ 
checkVisibility = value; 
if(checkVisibility == true) 
this.btnSecond.Visible = true; 
else 
this.btnSecond.Visible = false; 
} 
} 
} 
} 
************************************************* Main Web Page That hosts both user 
control ************************************************ 
using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Web; 
using System.Web.SessionState; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.HtmlControls; 
namespace UserControlTry 
{ 
public class WebForm1 : System.Web.UI.Page 
{ 
protected FirstButton FirstButton1; 
protected SecondButton SecondButton1; 
private void Page_Load(object sender, System.EventArgs e) 
{ 
if(!IsPostBack) 
         FirstButton1.Load += new System.EventHandler(FirstButton1.btnFirst_Click); 
checkForButtonsVisibility(); 
} 
public void checkForButtonsVisibility() 
{ 
if(FirstButton1.HasClicked == true) 
SecondButton1.setVisibility = false; 
else 
SecondButton1.setVisibility = true; 
} 
} 
} 
**************************************************************************************************************************************
 
Now the problem and the issue that i was facing was that series of event take place 
like this : 
1. Main Page Load event . 
2. User Control's Load Event . 
3. User Control's button's Click Event . 
so in normal case it use to work but for second button to vanish first button has to 
be clicked twice , because page load of web page use to take place before user control 
 , so what i did was made that event public and set it on load of user control , so it 
started happening in first shot but had to compromise with security , 
i hope u can get it , i think sarvana's solution is also really good and neat way to 
get things done , 
Please get back to me in case of any discrepancy , 
Regards , 
Mrinal

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to