master page treeview control treenodechanged event called from my content page but in one case event does not called

Hi All,

I have a Treeview control at my master page and from my content page I show user interface based on TreeNodeChanged, Treenodechanged event from my content page but in one case this event does not executing.  I checked using trace and debug but this event does not fired from my content page in one case only, all other case it work perfectly.

// here I am triggering node changeEvent but in one case it does not even called................

protected void Page_Init(object sender, EventArgs e)

{

Trace.Write(
"Content Page", "Page_Init");

myMaster = (MasterPage)Page.Master;

TreeView tree = this.myMaster.tree;myMaster.masterNodeChanged += new CommandEventHandler(myMaster_masterNodeChanged);

}

// here i process node chage Event at my content page

private void myMaster_masterNodeChanged(object sender, CommandEventArgs e)

{

Trace.Write("Content Page Master Page nodeChanged", "Masterpage NodeChanged");

string nodeText = e.CommandName;

int nodeValue = Int32.Parse(e.CommandArgument.ToString());

}

// Coding syntax all fine .

MasterPage
Event- Fire OnSelectedNodeChanged
here i m firing event of my content page (calling my nodechange event)
call masternodechanged event

ContentPage
Implement Masternodechanged event

but sometime my event does not trigger, as I checked in debug mode not even at master page method get called from where i calling the event of contentpage.

Any Idea friends.

Thanks,

Vivek 

 

0
vivek_cs
11/5/2008 5:52:07 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

12 Replies
1147 Views

Similar Articles

[PageSpeed] 58

Hi Vivek,

vivek_cs:
myMaster = (DPEMasterPage)Page.Master;

It seems that you have rewrited the master page, if so please refer this article to solve this problem, and check the parts of  "Abstract Interaction"

http://www.odetocode.com/Articles/450.aspx


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
11/10/2008 8:26:48 AM

Hi Hong-Gang,

Thanks for your reply but I am not sure whether that link will really help me as I am not even able to understand that in one situation why not event is triggering and that happened some times, some times it do worked.. quite confused.. might be something wrong in coding part somewhere...

Should I sent code to you to review, Most probably that would help you and certainly me.. To know the flaw.

Thanks.

Vivek 

 

 

 

0
vivek_cs
11/10/2008 3:25:06 PM

vivek_cs:

Hi Hong-Gang,

Thanks for your reply but I am not sure whether that link will really help me as I am not even able to understand that in one situation why not event is triggering and that happened some times, some times it do worked.. quite confused.. might be something wrong in coding part somewhere...

Should I sent code to you to review, Most probably that would help you and certainly me.. To know the flaw.

Thanks.

Vivek 

Hi Vivek,

Yes, you can post code here for us checking.

By the way, have you read the part of " Abstract Interaction"?  I think perhaps it can help you to solve this problem, it is very short, but useful for this problem.

 


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
11/11/2008 8:41:44 AM

 Hi Hong-Gang Chen

      I have created one website with Master and content page . I have taken TreeView Control on master page. And I wants that when I click to tree node the value of tree node is added to Session and data from database regarding to that tree node value.
Will fetch the records and load that on content page on Content Page Load event.
   

      But the problem is that When click tree node the fallowing events occurs
     
1) Content Page Load Event
2) Master Page Load Event
3) Master Page TreeNode Click Event
4) Content Page Load Event

 By these events it creates problem to fetch the data from database because Content Page didn’t get tree node value even if it get the value that is old one ….

       
   So can you know how to solve this problem ………?
                                              
                                             Thank You….In advance…

0
hiral
11/21/2008 10:42:48 AM

hiral shah:

 Hi Hong-Gang Chen

      I have created one website with Master and content page . I have taken TreeView Control on master page. And I wants that when I click to tree node the value of tree node is added to Session and data from database regarding to that tree node value.
Will fetch the records and load that on content page on Content Page Load event.
   

      But the problem is that When click tree node the fallowing events occurs
     
1) Content Page Load Event
2) Master Page Load Event
3) Master Page TreeNode Click Event
4) Content Page Load Event

 By these events it creates problem to fetch the data from database because Content Page didn’t get tree node value even if it get the value that is old one ….

       
   So can you know how to solve this problem ………?
                                              
                                             Thank You….In advance…

Hi hiral shah,

I suggest you open a new thread and give it a suitable title, and tell me the link.

 


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
11/26/2008 5:36:49 AM

Hi Hong-Gang Chen, 

Still I am waiting for my answer, I did send u the relevant code, please chek ur message, could u please look into that, I need to resolve this issue, Please help me out.

Thanks,

Vivek

 

0
vivek_cs
11/26/2008 12:12:28 PM

Thank you Vivek For your Reply

My Problem is solved yesterday

0
hiral
11/26/2008 12:54:13 PM

vivek_cs:

Hi Hong-Gang Chen, 

Still I am waiting for my answer, I did send u the relevant code, please chek ur message, could u please look into that, I need to resolve this issue, Please help me out.

Thanks,

Vivek

 

Hi Vivek,

Sorry, could post your code here?


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
11/27/2008 2:02:31 AM

Hi Chen,

Thanks for replying to my post (http://forums.asp.net/t/1343905.aspx), I did check abstract interation, I used the same in my project as well, Still I don't know what I cause the problem as in one case sometime event does not trigger.

One point still I notice is that I am using two events at my content page to call node change event of my mater page (in my case it is treeview control).

These two events are at my content page..

protected void Page_Init(object sender, EventArgs e)

{

Trace.Write(
"Content Page", "Page_Init");

myMaster = (MasterPage)Page.Master;

TreeView tree = this.myMaster.tree; myMaster.masterNodeChanged += new CommandEventHandler(myMaster_masterNodeChanged);

}

These page events are Page_Init and Page_PreRenderprotected void Page_PreRender(object sender, EventArgs e)

{

Trace.Write("Content Page", "Page_PreRender");

myMaster = (MasterPage)Page.Master;

TreeView tree = this.myMaster.tree;

string strComments = txtRatingComments.Text; // You need to nullify control value

myMaster.masterNodeChanged += new CommandEventHandler(myMaster_masterNodeChanged);

int factid;if (ViewState["factid"] != null)

{

factid =
Convert.ToInt32(ViewState["factid"]);if (factid != -1)

{

ShowHide(
"Message", "key", "CommentDiv");

}

else if (factid == -1)

{

ShowHide(
"Message", "key", "evaluation");

}

}

}

based on these two events I am doing other coding..One more more relevant function at the content page is --

private void myMaster_masterNodeChanged(object sender, CommandEventArgs e)

{

string strRetMsg = string.Empty;

Trace.Write("Content Page", "NodeChanged");

if ((Session["EvalStatusCode"].ToString() != Constants.strDsgnEvalStatCdFinalSubmitted) && (Session["EvalStatusCode"].ToString() != Constants.strDsgnEvalStatCdSubmitted))

{

strRetMsg = SaveEvaluation(
Constants.strDsgnEvalStatCdInProgress);if (string.Equals(strRetMsg, "SUCCESS"))

{

Session[
"EvalStatusCode"] = Constants.strDsgnEvalStatCdInProgress;

}

}

 

string nodeText = e.CommandName; int nodeValue = Int32.Parse(e.CommandArgument.ToString());

// before assigning to viewstate I would be having old value..

// validation check.. This is to check that error will be removed when rating values are providedif (ViewState["TreeNode"] != null)

{

m_arrayList = (
ArrayList)ViewState["TreeNode"];if (m_arrayList.Count == 0)

{

hideSelectedNode(
Convert.ToInt32(ViewState["factid"]));

ShowSelectedNode(nodeValue);//m_arrayList.Clear();

}

else

{

//int iFactId = int.Parse(ViewState["factid"].ToString());bool bTrue = RemoveItem(m_arrayList);if (!m_arrayList.Contains(ViewState["factid"]))

{

if ((m_rateVal != 0))

{

int iMinVal = Convert.ToInt32(hdnminVal.Value.ToString());

int iMaxVal = Convert.ToInt32(hdnmaxVal.Value.ToString());if (!((m_rateVal > 0) && (m_rateVal <= 5)) && (m_rateVal != 0))

{

// no factor selected then add factorm_arrayList.Add(ViewState["factid"]);

ShowList();

}

if ((Convert.ToInt32(m_rateVal) >= iMaxVal) || ((Convert.ToInt32(m_rateVal) <= Convert.ToInt32(iMinVal)))) //|| (Convert.ToInt32(m_rateVal) == 0))

{

if (txtRatingComments.Text == string.Empty)

{

m_arrayList.Add(ViewState[
"factid"]);

ShowList();

}

}

}

}

if (!m_arrayList.Contains(ViewState["factid"]))hideSelectedNode(Convert.ToInt32(ViewState["factid"]));

}

}

else

hideSelectedNode(Convert.ToInt32(ViewState["factid"]));

ViewState["factid"] = Convert.ToString(nodeValue);txtRatingComments.Text = string.Empty;if (nodeValue != -1)

{

ShowHide(
"Message", "key", "CommentDiv");

PopulateEvaluation(nodeValue);

Trace.Write("CommentDiv");

}

else

{

ShowHide(
"Message", "key", "evaluation");

Trace.Write("evaluation");

PopulateComment(); // showcomment visible

}

if (ViewState["TreeNode"] != null)

{

string strObj = nodeValue.ToString(); m_arrayList = (ArrayList)ViewState["TreeNode"];

if (!m_arrayList.Contains(strObj)) // for Available Factors I don't want to Show

ShowSelectedNode(nodeValue);

}

else

ShowSelectedNode(nodeValue);

}

At my master page (code behind)

protected void Tree_Select(Object source, EventArgs e)

{

if (Tree.SelectedNode.Value != null && masterNodeChanged != null) masterNodeChanged(this, new CommandEventArgs(Tree.SelectedNode.Text, Tree.SelectedNode.Value));

}

Master Aspx relevant code

<
asp:TreeView ID="Tree" runat="server" OnSelectedNodeChanged="Tree_Select" ExpandImageUrl="~/Images/spacer.gif" NoExpandImageUrl="~/Images/spacer.gif"

CollapseImageUrl="~/Images/spacer.gif"

ExpandDepth="0" NodeIndent="15" />

Actually I can't post my whole relevant code there as its public forum and violation of law, Which I don't want, If you are okay

I may sent it to you, if you can look it to, As its based on master and content page, you might need to look two pages.

Thanks for your time.

if you can want I may give the source file in that way you may be more comfortable

Thanks,

Vivek 

0
vivek_cs
12/4/2008 7:44:50 PM

Hi Chen,

Thanks for replying to my post (http://forums.asp.net/t/1343905.aspx), I did check abstract interation, I used the same in my project as well, Still I don't know what I cause the problem as in one case sometime event does not trigger.

One point still I notice is that I am using two events at my content page to call node change event of my mater page (in my case it is treeview control).

These two events are at my content page..

protected void Page_Init(object sender, EventArgs e)

{

Trace.Write(
"Content Page", "Page_Init");

myMaster = (MasterPage)Page.Master;

TreeView tree = this.myMaster.tree; myMaster.masterNodeChanged += new CommandEventHandler(myMaster_masterNodeChanged);

}

These page events are Page_Init and Page_PreRenderprotected void Page_PreRender(object sender, EventArgs e)

{

Trace.Write("Content Page", "Page_PreRender");

myMaster = (MasterPage)Page.Master;

TreeView tree = this.myMaster.tree;

string strComments = txtRatingComments.Text; // You need to nullify control value

myMaster.masterNodeChanged += new CommandEventHandler(myMaster_masterNodeChanged);

int factid;if (ViewState["factid"] != null)

{

factid =
Convert.ToInt32(ViewState["factid"]);if (factid != -1)

{

ShowHide(
"Message", "key", "CommentDiv");

}

else if (factid == -1)

{

ShowHide(
"Message", "key", "evaluation");

}

}

}

based on these two events I am doing other coding..One more more relevant function at the content page is --

private void myMaster_masterNodeChanged(object sender, CommandEventArgs e)

{

string strRetMsg = string.Empty;

Trace.Write("Content Page", "NodeChanged");

if ((Session["EvalStatusCode"].ToString() != Constants.strDsgnEvalStatCdFinalSubmitted) && (Session["EvalStatusCode"].ToString() != Constants.strDsgnEvalStatCdSubmitted))

{

strRetMsg = SaveEvaluation(
Constants.strDsgnEvalStatCdInProgress);if (string.Equals(strRetMsg, "SUCCESS"))

{

Session[
"EvalStatusCode"] = Constants.strDsgnEvalStatCdInProgress;

}

}

 

string nodeText = e.CommandName; int nodeValue = Int32.Parse(e.CommandArgument.ToString());

// before assigning to viewstate I would be having old value..

// validation check.. This is to check that error will be removed when rating values are providedif (ViewState["TreeNode"] != null)

{

m_arrayList = (
ArrayList)ViewState["TreeNode"];if (m_arrayList.Count == 0)

{

hideSelectedNode(
Convert.ToInt32(ViewState["factid"]));

ShowSelectedNode(nodeValue);//m_arrayList.Clear();

}

else

{

//int iFactId = int.Parse(ViewState["factid"].ToString());bool bTrue = RemoveItem(m_arrayList);if (!m_arrayList.Contains(ViewState["factid"]))

{

if ((m_rateVal != 0))

{

int iMinVal = Convert.ToInt32(hdnminVal.Value.ToString());

int iMaxVal = Convert.ToInt32(hdnmaxVal.Value.ToString());if (!((m_rateVal > 0) && (m_rateVal <= 5)) && (m_rateVal != 0))

{

// no factor selected then add factorm_arrayList.Add(ViewState["factid"]);

ShowList();

}

if ((Convert.ToInt32(m_rateVal) >= iMaxVal) || ((Convert.ToInt32(m_rateVal) <= Convert.ToInt32(iMinVal)))) //|| (Convert.ToInt32(m_rateVal) == 0))

{

if (txtRatingComments.Text == string.Empty)

{

m_arrayList.Add(ViewState[
"factid"]);

ShowList();

}

}

}

}

if (!m_arrayList.Contains(ViewState["factid"]))hideSelectedNode(Convert.ToInt32(ViewState["factid"]));

}

}

else

hideSelectedNode(Convert.ToInt32(ViewState["factid"]));

ViewState["factid"] = Convert.ToString(nodeValue);txtRatingComments.Text = string.Empty;if (nodeValue != -1)

{

ShowHide(
"Message", "key", "CommentDiv");

PopulateEvaluation(nodeValue);

Trace.Write("CommentDiv");

}

else

{

PopulateComment(); // showcomment visible

}

if (ViewState["TreeNode"] != null)

{

string strObj = nodeValue.ToString(); m_arrayList = (ArrayList)ViewState["TreeNode"];

if (!m_arrayList.Contains(strObj)) // for Available Factors I don't want to Show

ShowSelectedNode(nodeValue);

}

else

ShowSelectedNode(nodeValue);

}

At my master page (code behind)

protected void Tree_Select(Object source, EventArgs e)

{

if (Tree.SelectedNode.Value != null && masterNodeChanged != null) masterNodeChanged(this, new CommandEventArgs(Tree.SelectedNode.Text, Tree.SelectedNode.Value));

}

Master Aspx relevant code

<
asp:TreeView ID="Tree" runat="server" OnSelectedNodeChanged="Tree_Select" ExpandImageUrl="~/Images/spacer.gif" NoExpandImageUrl="~/Images/spacer.gif"

CollapseImageUrl="~/Images/spacer.gif"

ExpandDepth="0" NodeIndent="15" />

Actually I can't post my whole relevant code there as its public forum and violation of law, Which I don't want, If you are okay

I may sent it to you, if you can look it to, As its based on master and content page, you might need to look two pages.

Thanks for your time.

if you can want I may give the source file in that way you may be more comfortable

Thanks,

Vivek 

0
vivek_cs
12/4/2008 7:44:53 PM

What is "DPEMasterPage"?

In order to help you further, could try to post a workable code here?


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
12/5/2008 2:06:11 AM

MasterPage is name of master page class. This is the working code and code deployed but in one scenario I am getting problem and event is not triggering So I was not able to check. Thanks a lot for your time.

0
vivek_cs
12/5/2008 2:24:20 PM
Reply:

Similar Artilces:

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

Master Page's Page Load firing twice on events called from other Page events
I have numerous pages tied to my MasterPage that controls 2 Always visible extenders for User Reminders and a Counter. I would like them to only fire on a Page_Load once, not twice. I have read a million posts about AutoEventWireupset to false, but on all my pages it is set to true and on those pages the events only fire once. The Master page is giving me problems on events firing twice. Any suggestions? here is some code... protected void Page_Load(object sender, EventArgs e) {if (!Page.Master.IsPostBack) {  I call 2 stored procedures here that should only fire once on a Page_Lo...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

From a content page, calling function of control on master page
I've got a master page with a user control on it. The user control class has a public function. Is it possible to call this function from a content page? Also, in doing so, I need to pass a bool to said function. And if it is, how?An example would be very helpful. I'm still learning the 2.0 features. Thanks! Reference this article: Passing Information Between Content and Master Pageswww.hopeasp.net...

Problem to use TreeView Control in a 'content page' This Error Occur "Only Content controls are allowed directly in a content page that contains Content controls."
hi I am trying to use the TreeView Control inside the content page (Page that has a master page is a content page). On compiling the project I got the following ASP.Net runtime error: "Only Content controls are allowed directly in a content page that contains Content controls."B@b@R J Issue resolved. I was putting script tag in the content page that is not allowed. when remove the script from content page problem is resolved.B@b@R J...

User Control in Master page raises "clicked" event...how to subscribe to this event in "nested" Master page??
I have a custom user control with several LinkButtons that serve as a common menu for all my pages.  Within this user control, I created a delegate and a custom event...and raise a "clicked" event whenever one of the LinkButtons is clicked. I added this user control to a Master page, then subscribed to that "clicked" event in the Page_Load.  The subscribed event handler within this Master page works fine. My problem is...I created a "nested" Master page from the Master page above, and want to subscribe to the original user control...

Calling a method from a control page on the axpx page where the control page exists.
Hello,  I have an .aspx page that has a method called grdMain_DataBind().  I have a control page that loads within the aspx page which has its own logic.  I have a button on my control page called "SAVE".  How can I call the method grdMain_DataBind thats in my aspx logic from the control that exists on that page when I click SAVE button.  Is there a way? If I were you, I'd simply create a "Save" Event within your control. When the Button in your control is pressed, in the Click handler for that Button you can raise the event. Then, within t...

Controls & Events in Master Page handlers in Content Page
Hello all, My question is, is it possible to have a common set of controls in the master page and have the event handlers for those controls in the content page But all Javascript. The OnClick, OnLoad events for a set of controls must be handled differently in different pages. I do not require any server side event handlers but all the event handlers are Javascript functions. If yes, could you provide links that have some sample code. Thanks You can't do it from the master page, but can from each content page. What you'll need to do is access the controls on the master page&n...

accessing controls in master page and adding event to content page
Hi  I've currently got a control on my master page and i'm trying to write an even on the content page that fires when the button is clicked, I don't think it is working though. Can someone help? The code is below:  masterpage <asp:ImageButton id="imgButton" runat="server"/> code behind Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load, Me.Load Public ReadOnly Property lnkbFromMasterPage() As ImageButtonGetReturn imgButtonEnd GetEnd Property  content page code behind: Public Sub Page_Load(ByVa...

Calling a Page_load event of Content Page inside master page?
How can I call a simple function defined in my content page from a master page?   Well if you're going to have the same method in multiple pages I would create an interface with the method defined and then implement that method in the pages.  That way in your masterpage you can test the Page property to see if it implements that interface and if so cast it to that type and call the method. Rob Millswww.dotnetadvisor.com Hi, You can try to refer this article: Passing Information Between Content and Master Pages Hope it helps.Amanda WangMicrosoft Online Community Supp...

Access Master Page control in Content Page and Process Events
<p> Hi All, At My Master Page , I have TreeView control and I am binding this treeview from one of my content page. Which is fine. Now At the same content page I want to detect the click event on the treenode and accessing selectedNode. How do I do that Which Event I need to use at my content page. Please suggest me. Basically I want to retrieve my TreeNode ID. As in case of TreeView I know the id (TreeView name) so I can find my treecontrol but here selected TreeNode can be anything and depend on Selected TreeNode value I will be showing data in my user interface. thanks in ad...

Master Page literal control text not updating when called from content page
Hi all,I have a Master page with a literal control named litSignInStatus. The litSIgnInStatus.text gets set on the Masters page load event...Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        If HttpContext.Current.User.Identity.IsAuthenticated Then            SetSignInStatusText(SignInStatusText.SignedIn)        Else            SetSignInStatusText(SignInStatusText.S...

how to call one page's page_load event from master page
hi i m using a master page and i simply want to call the page load event of the aspx page(which contains master page)from master page. is it possible? how can i do this? thanks in advance. shweta   ThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path You shouldn't need to do that. Page_Load will be called automatically. The IIS runtime is responsible for calling the Page_Load() event.  I don't think there is a practical way to call a Page load event from the master page.  I can't really thi...

Web resources about - master page treeview control treenodechanged event called from my content page but in one case event does not called - asp.net.navigation-controls

Resources last updated: 1/3/2016 8:29:28 AM