473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Page and User Control Communication?

I have a aspx page with one user control , in the user control i have hidden
field (name hdnSaved) runat server wrapped in property like following :-
in documentview.ascx
public string SaveClicked
{
get
{
return (hdnSaved == null) ? "" : hdnSaved.Text;
}
set
{
hdnSaved.Text = value;
}
}
inside aspx page
declaration of UC
protected DocumantViewer Documentview1;
private void Page_Load(object sender, System.EventArgs e)
{
//here when I called Documentview1.SaveClicked while debug and I put the
//breakpoint in the user control get section the hdnSaved set as (undefined)
why???
if(Documentview1.SaveClicked == "true" || Documentview1.SaveClicked == "")
{
//do something
}
else
{
Documentview1.ShowFolder();
}

}

Nov 19 '05 #1
2 1744
Raed:
Simple question, but you do have
protected HtmlInputHidden hdnSaved;

declared in the documentview.ascx.cs (codebehind) and <input type="hidden"
runat="server" id="hdnSave" /> in the aspx?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.com...
I have a aspx page with one user control , in the user control i have hidden field (name hdnSaved) runat server wrapped in property like following :-
in documentview.ascx
public string SaveClicked
{
get
{
return (hdnSaved == null) ? "" : hdnSaved.Text;
}
set
{
hdnSaved.Text = value;
}
}
inside aspx page
declaration of UC
protected DocumantViewer Documentview1;
private void Page_Load(object sender, System.EventArgs e)
{
//here when I called Documentview1.SaveClicked while debug and I put the //breakpoint in the user control get section the hdnSaved set as (undefined) why???
if(Documentview1.SaveClicked == "true" || Documentview1.SaveClicked == "") {
//do something
}
else
{
Documentview1.ShowFolder();
}

}

Nov 19 '05 #2
Hi Raed,

You only declare the usercontrol but not assign any
reference to it. So it's null (undefined). In order to use
it, you have to get its reference. You can get its
reference from its Control ID. In aspx page look at HTML
code, find something like
<uc1: Documentview1 id="Documentview11"
runat="server"></uc1: Documentview1>.

So the ID is Documentview11.

In Page_Load
Documentview1 = (Documentview)this.FindControl
("Documentview11");
// Then you can use the Documentview1

HTH

Elton Wang
el********@hotmail.com
-----Original Message-----
I have a aspx page with one user control , in the user control i have hiddenfield (name hdnSaved) runat server wrapped in property like following :-

in documentview.ascx
public string SaveClicked
{
get
{
return (hdnSaved == null) ? "" : hdnSaved.Text; }
set
{
hdnSaved.Text = value;
}
}
inside aspx page
declaration of UC
protected DocumantViewer Documentview1;
private void Page_Load(object sender, System.EventArgs e)
{
//here when I called Documentview1.SaveClicked while debug and I put the//breakpoint in the user control get section the hdnSaved set as (undefined)why???
if(Documentview1.SaveClicked == "true" || Documentview1.SaveClicked == "") {
//do something
}
else
{
Documentview1.ShowFolder();
}

}

.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wee Bubba | last post by:
my user control (usercontrol1.ascx) is added dynamically into a placeholder on page_load. within usercontrol1.ascx there is a button. When a user presses this button I want the page to reload with...
1
by: Marc Jennings | last post by:
Hi there, I have an ASP.NET page that includes the following items. public string s1; public string s2; public string s3; and a User control called TestForm with three text boxes and one...
2
by: Willy | last post by:
Hi All! Is there any ways to get access to the controls contained in another user controls from an ASP.NET page? For example I have... - User Control A |_ User Control B (which uses User...
8
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
4
by: darrel | last post by:
Karl has helped me in the past in regards to communicating between controls and pages: http://www.openmymind.net/communication/index.html#3.1 I ended up going down the interfaces path and...
2
by: eagle | last post by:
How do I access a control, like a placeholder, from another page, or another user control that may be on the same page. For instance, I have a web page with 2 user controls. One user controls...
0
by: robgallen | last post by:
I have 2 user controls within a master page, and I would like one of them to call a function in the other. All the examples I have seen involve a page communicating with the Master page, or with...
6
by: ajk | last post by:
Hi I was wondering how to show different properties in design and run-mode for a user control? Is it possible to do this when implementing the System.ComponentModel.ICustomTypeDescriptor...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.