Click here to Skip to main content
16,006,749 members
Home / Discussions / C#
   

C#

 
AnswerRe: ApplicationDeployment & HttpUtility Pin
Wendelius7-Sep-08 3:50
mentorWendelius7-Sep-08 3:50 
QuestionCreating custom controls Pin
Dewald6-Sep-08 20:24
Dewald6-Sep-08 20:24 
AnswerRe: Creating custom controls Pin
DaveyM696-Sep-08 23:46
professionalDaveyM696-Sep-08 23:46 
Questionerror: Exception has been thrown by the target of an invocation Pin
mehrnoosh6-Sep-08 19:15
mehrnoosh6-Sep-08 19:15 
AnswerRe: error: Exception has been thrown by the target of an invocation Pin
mehrnoosh8-Sep-08 20:22
mehrnoosh8-Sep-08 20:22 
QuestionHow can I get full path for a directory or file which I clicked on desktop or sth else in startup my application?? Pin
ersingenel6-Sep-08 14:56
ersingenel6-Sep-08 14:56 
AnswerRe: How can I get full path for a directory or file which I clicked on desktop or sth else in startup my application?? Pin
Ashfield7-Sep-08 8:46
Ashfield7-Sep-08 8:46 
Questiondynamic loaded ascx delegate event not firing in the parent form Pin
cmello6-Sep-08 14:11
cmello6-Sep-08 14:11 
I have am dynamically loading a web user control based on the click of a tab strip
I load the default control for the first tab in the page load event after checking page is not postback. After that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the delegate so the parent can handle the click of the edit button in the user control. Honestly I am not very good at event delegation the code complies but I never get the command to execute on the parent

in the child control site.ascx I set up the datalist public event with code below

public partial class Site : System.Web.UI.UserControl
{
public delegate void myItemCommand(object source, DataListCommandEventArgs e);
public event myItemCommand dlSiteItemCommand;

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{ }


protected void dlSite_ItemCommand(object source, DataListCommandEventArgs e)
{
if (dlSiteItemCommand != null)
dlSiteItemCommand(source, e);
}

protected void Page_Load(object sender, EventArgs e)
{ //get the data and fill the datalist }

in the parent (Detail) I try to bind to the event in the Site.ascx When the page loads in the parent the procedure LoadUserControl()
is called and in it after I dynamically load the correct control, I caste the generic control to an instance of Site so I can see the public event I created. Thats where I have got it wrong I am SOOOOO confused. The binding does not work when I click the edit button in the child datalist I never break into the event that is bound on the parent Below is parent code. Please I not this is too long an explanation but I have been trying and reading a long time.

Cindy

public partial class Detail : System.Web.UI.Page
{
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}
private void LoadUserControl()
{
string controlPath = LastLoadedControl;

if (!string.IsNullOrEmpty(controlPath))
{
PlaceHolder1.Controls.Clear();
UserControl uc = (UserControl)LoadControl(controlPath);
if (controlPath == "Site.ascx")
{
Site ucSite = (Site)uc;
ucSite.dlSiteItemCommand += new Site.myItemCommand(ucSite_dlSiteItemCommand);
}
PlaceHolder1.Controls.Add(uc);
}
}

void ucSite_dlSiteItemCommand(object source, DataListCommandEventArgs e)
{
(source as DataList).EditItemIndex = e.Item.ItemIndex;
(source as DataList).DataSource = dsTunnel;
(source as DataList).DataBind();
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{}

protected void Page_Load(object sender, EventArgs e)
{
if(!(Page.IsPostBack))
{
string controlPath = null;
controlPath = "Site.ascx";
LastLoadedControl = controlPath;
LoadUserControl();
}
LoadUserControl();
}
private void ts_SelectionChanged(object sender, JQD.TabStrip.SelectionChangedEventArgs e)
{
int TabPos = e.TabPosition;
ActiveTab = TabPos;
string controlPath = string.Empty;

switch (TabPos)
{
case 0:
controlPath = "Site.ascx";
LastLoadedControl = controlPath;
LoadUserControl();
break;

case 1:
break;
}
QuestionRandom method Pin
MorganSim6-Sep-08 13:10
MorganSim6-Sep-08 13:10 
AnswerRe: Random method Pin
Blue_Boy6-Sep-08 13:44
Blue_Boy6-Sep-08 13:44 
QuestionRe: Random method Pin
MorganSim6-Sep-08 23:04
MorganSim6-Sep-08 23:04 
RantRe: Random method Pin
Guffa6-Sep-08 23:21
Guffa6-Sep-08 23:21 
AnswerRe: Random method Pin
Guffa6-Sep-08 22:56
Guffa6-Sep-08 22:56 
QuestionRe: Random method Pin
MorganSim6-Sep-08 23:19
MorganSim6-Sep-08 23:19 
AnswerRe: Random method Pin
Guffa6-Sep-08 23:38
Guffa6-Sep-08 23:38 
QuestionRe: Random method Pin
MorganSim7-Sep-08 0:08
MorganSim7-Sep-08 0:08 
AnswerRe: Random method Pin
Guffa7-Sep-08 0:28
Guffa7-Sep-08 0:28 
GeneralAm I welcome! Pin
MorganSim6-Sep-08 12:55
MorganSim6-Sep-08 12:55 
GeneralRe: Am I welcome! Pin
Blue_Boy6-Sep-08 13:02
Blue_Boy6-Sep-08 13:02 
General[Message Deleted] Pin
MorganSim6-Sep-08 13:21
MorganSim6-Sep-08 13:21 
GeneralRe: Am I welcome! Pin
Blue_Boy6-Sep-08 13:41
Blue_Boy6-Sep-08 13:41 
GeneralRe: Am I welcome! Pin
MorganSim6-Sep-08 22:41
MorganSim6-Sep-08 22:41 
GeneralRe: Am I welcome! Pin
Blue_Boy6-Sep-08 22:46
Blue_Boy6-Sep-08 22:46 
QuestionRe: Multiple forms Pin
MorganSim6-Sep-08 23:25
MorganSim6-Sep-08 23:25 
QuestionRPC and permissions on new process Pin
erikkl20006-Sep-08 6:20
erikkl20006-Sep-08 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.