473,385 Members | 1,597 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,385 software developers and data experts.

reading labels from an user control

Hello,

I have the following user control called encabezado (I cut some parts
of the code to make it shorter):

public partial class Encabezado : System.Web.UI.UserControl {
private String n;
public Encabezado()
{
//
// TODO: Add constructor logic here
//
}
public String estado
{
get
{
return lbl_estado.Text.ToString();
}
set
{
lbl_estado.Text = value;
}
}
public String numero
{
get
{
return n;
}
set
{
n = value;
}
}
private void page_load()
{
mostrar_encabezado(n);
}
private void mostrar_encabezado(String numero)
{

//Here I have a SQL Query and then:

lbl_nro.Text = Request.QueryString["reclamo"].ToString();
lbl_sucu.Text = dt.Rows[0]["nombre_sucu"].ToString();
lbl_titulo.Text = dt.Rows[0]["titulo_rec"].ToString();
lbl_usuario.Text = dt.Rows[0]["usuario_rec"].ToString();
lbl_asignado.Text = dt.Rows[0]["asignado_a_rec"].ToString();
lbl_estado.Text = dt.Rows[0]["estado_rec"].ToString();
lbl_icono_asig.Text = "";

// later use these to make a table, but it's not usefull for this
context.
}
}
To use the control I do:

<hparis:encabezado ID="encabezado1" runat="server" />

On the code:
encabezado1.numero = Request.QueryString["reclamo"];
And it works. Even the labels (lbl_estado.Text) are printed correctly
according to the specified number.
But when I try to use encabezado1.estado (i.e.:
Response.Write(encabezado1.estado)) I receive an empty String.
I only can access to encabezado1.numero, but no the others. Why is that
?

What am I doing wrong ?

greetings,

hans

Jan 10 '07 #1
5 1135

Hans wrote:
And it works. Even the labels (lbl_estado.Text) are printed correctly
according to the specified number.
But when I try to use encabezado1.estado (i.e.:
Response.Write(encabezado1.estado)) I receive an empty String.
Hi,
It depends on the place where you want to use Response.Write. It is not
clearly stated so I make some supposition...
It can happen if you place one control (ChildControl.ascx) on another
control or page (ParentControl.ascx) and call a property of
ChildControl in the page load event handler of ParentControl. Because
page load event handler of ChildControl does not occur your property is
empty.

Jan 10 '07 #2
Hello and thanks for your answer.

I use my user control on a page called "mostrar.aspx" and I put the
"Response.Write" on the same page. Any ideas ?

hans

marss wrote:
Hans wrote:
And it works. Even the labels (lbl_estado.Text) are printed correctly
according to the specified number.
But when I try to use encabezado1.estado (i.e.:
Response.Write(encabezado1.estado)) I receive an empty String.

Hi,
It depends on the place where you want to use Response.Write. It is not
clearly stated so I make some supposition...
It can happen if you place one control (ChildControl.ascx) on another
control or page (ParentControl.ascx) and call a property of
ChildControl in the page load event handler of ParentControl. Because
page load event handler of ChildControl does not occur your property is
empty.
Jan 12 '07 #3

Hans wrote:
Hello and thanks for your answer.

I use my user control on a page called "mostrar.aspx" and I put the
"Response.Write" on the same page. Any ideas ?

hans
Hello,
Where specifically on a page? If it happens in the Page_Load event
hadler then I discribed this situation above, if in another place - I
have no idea :(

Jan 12 '07 #4
Hello,

This is what I do on the Page_load event of "mostrar.aspx.cs".

protected void Page_Load()
{
encabezado1.numero = Request.QueryString["reclamo"];

Response.Write("asignado: '" + encabezado1.asignado + "'");
//it prints an empty string
Response.Write("numero: "' + encabezado1.numero + "'");
//it prints the string I asigned above.

//some other code that isn't relevant.
}

Where should I put the 1st. response write ? Why numero is returned
correctly if it's also asigned on the Page_Load event ? I'm kinda new
to the .NET.

hans

marss wrote:
Hans wrote:
Hello and thanks for your answer.

I use my user control on a page called "mostrar.aspx" and I put the
"Response.Write" on the same page. Any ideas ?

hans

Hello,
Where specifically on a page? If it happens in the Page_Load event
hadler then I discribed this situation above, if in another place - I
have no idea :(
Jan 12 '07 #5

Hans wrote:
Hello,

This is what I do on the Page_load event of "mostrar.aspx.cs".

protected void Page_Load()
{
encabezado1.numero = Request.QueryString["reclamo"];

Response.Write("asignado: '" + encabezado1.asignado + "'");
//it prints an empty string
Response.Write("numero: "' + encabezado1.numero + "'");
//it prints the string I asigned above.

//some other code that isn't relevant.
}

Where should I put the 1st. response write ? Why numero is returned
correctly if it's also asigned on the Page_Load event ? I'm kinda new
to the .NET.
Hi, Hans
Request pipeline:
1.Page load (Page, mostrar.aspx in your case).
2.Page load (Control, encabezado.ascx in your case).
3.Event handlers of controls placed on mostrar.aspx.

You are trying to access at step 1 to property that will be initilized
at step 2 only.
One of the solutions:
Rewrite some code in Encabezado:

.....
public String numero
{
get
{
return n;
}
set
{
n = value;
mostrar_encabezado(n);
}
}
private void page_load()
{
}
.....

Jan 15 '07 #6

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

Similar topics

4
by: Mateo | last post by:
Hi! I have labels on my page (some are web forms controls, and some are plain HTML labels), and I need Mozilla compatibile way for reading label value. For example, in IE I can use this:...
2
by: DBQueen | last post by:
I have a database which will be printing out labels for SMALL test tubes (1/4" high). We have yet to find a reasonably-priced printer (labelwriter) which can effectively print this on ROLLS of...
10
by: John Baker | last post by:
Hi: I have a user who has labels that are set up 3 across and 11 vertical (which is unusual at best), and he wants me to print names and addresses on them. I have already set up for labels 10...
2
by: Ahmed | last post by:
Hello everyone, I am using Visual Studio 2003 Enterprise Architect. Everytime I build the project, some of the labels move 2 pixels down. I even locked those labels. No Good. Any idea whats...
3
by: solar | last post by:
Is there a way that a user can set the position for a single label to print within an Access Label report? I guess I would like something like what is available in Word where the user can select...
3
by: Gary | last post by:
I have a bunch of labels, and want to put in some container, which should be: 1. The number of labels for each column is fixed, say 16/row. And the number of currently displaying rows is fixed,...
1
by: rn5a | last post by:
A ASPX page has a DataList control with a few Labels. This page also has a CheckBox which resides OUTSIDE the DataList. By default, this CheckBox is checked. If the CheckBox is checked, then the...
1
by: Hans | last post by:
Hello, It looks like my previous post was deleted. So here is again: I have this user control called "encabezado" (I cut the code to make it shorter): public partial class Encabezado :...
6
by: Blkpower | last post by:
Hi to all, I'm writing a windows form application that has a panel with some labels in it. I need to let the user move these labels with drag and drop inside the panel. How can I do it? I now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.