Showing posts with label webpage. Show all posts
Showing posts with label webpage. Show all posts

Monday, March 26, 2012

pass table back to webpage

I'm wondering what the best way to do the following:
I have a page with a table. I built a custom class that creates a
System.Web.UI.WebControls table object and return it to the webpage as a
property. But its not reading the table correctly. It doesnt see the
tablerows and tablecell objects.
First, I'm not sure why its not reading the table properly?
Second, I wonder if there's a better way to do this? Maybe a custom control?
I haven't really gotten into these yet. My table only contains some
hyperlinks to open other pages. so no other server-side processing after
this.What do you mean by "Not reading the table properly". If collections are
empty could it be you forgotten to add them asd they are created to your
table ?

Patrice

--

"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> I'm wondering what the best way to do the following:
> I have a page with a table. I built a custom class that creates a
> System.Web.UI.WebControls table object and return it to the webpage as a
> property. But its not reading the table correctly. It doesnt see the
> tablerows and tablecell objects.
> First, I'm not sure why its not reading the table properly?
> Second, I wonder if there's a better way to do this? Maybe a custom
control?
> I haven't really gotten into these yet. My table only contains some
> hyperlinks to open other pages. so no other server-side processing after
> this.
The table in the webpage is set to the returned table from the custom class
function. I know that there's data rows and cells in it.
on webpage:
objBusLog.FillTable(); //this is call to define the table
TblRpt = objBusLog.TblReports; //This sets table web control to actual
table being set in custom class.

??

"Patrice" wrote:

> What do you mean by "Not reading the table properly". If collections are
> empty could it be you forgotten to add them asd they are created to your
> table ?
> Patrice
> --
> "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> > I'm wondering what the best way to do the following:
> > I have a page with a table. I built a custom class that creates a
> > System.Web.UI.WebControls table object and return it to the webpage as a
> > property. But its not reading the table correctly. It doesnt see the
> > tablerows and tablecell objects.
> > First, I'm not sure why its not reading the table properly?
> > Second, I wonder if there's a better way to do this? Maybe a custom
> control?
> > I haven't really gotten into these yet. My table only contains some
> > hyperlinks to open other pages. so no other server-side processing after
> > this.
>
What I don't understand for now is the result you have.

Do you mean you have no HTML at all rendered for this table ?
If yes, it's likely this control is not part of the page.

Do you mean you have rows missing ? What if you show the rows count to see
if it's what you expect ?
If not it's likely rows are not added in the collection...

Etc...

Some basic code would be :

System.Web.UI.WebControls.Table TestFunction()
{
System.Web.UI.WebControls.Table t=new System.Web.UI.WebControls.Table();
System.Web.UI.WebControls.TableRow r=new
System.Web.UI.WebControls.TableRow();
System.Web.UI.WebControls.TableCell c=new
System.Web.UI.WebControls.TableCell();
r.Cells.Add(c);
t.Rows.Add(r);
return t;
}
void Page_Load(Object sender,System.EventArgs e)
{
Form1.Controls.Add(TestFunction());
}

(use "view source" in your browser to see that it renders an empty HTML
table).

Hope it helps...

Patrice

--

"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> The table in the webpage is set to the returned table from the custom
class
> function. I know that there's data rows and cells in it.
> on webpage:
> objBusLog.FillTable(); //this is call to define the table
> TblRpt = objBusLog.TblReports; //This sets table web control to actual
> table being set in custom class.
> ??
> "Patrice" wrote:
> > What do you mean by "Not reading the table properly". If collections are
> > empty could it be you forgotten to add them asd they are created to your
> > table ?
> > Patrice
> > --
> > "klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
> > news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> > > I'm wondering what the best way to do the following:
> > > I have a page with a table. I built a custom class that creates a
> > > System.Web.UI.WebControls table object and return it to the webpage as
a
> > > property. But its not reading the table correctly. It doesnt see the
> > > tablerows and tablecell objects.
> > > First, I'm not sure why its not reading the table properly?
> > > Second, I wonder if there's a better way to do this? Maybe a custom
> > control?
> > > I haven't really gotten into these yet. My table only contains some
> > > hyperlinks to open other pages. so no other server-side processing
after
> > > this.
Yes, the table is indeed a server side control. If I run the code directly in
the page_load, to build the table, all is good, like the way, your test
function is setup..

But in my case, I create a new class that creates the table. Then I get a
property as follows:
public System.Web.UI.WebControls.Table TblReports
{
get
{
return m_objTblRpts;
}
}}
When I print the number of rows in the web page, it comes back as 2. But it
doesnt actually print the rows of the table. It only prints the following:
<table id="TblRpts" border="0" style="width:928px;Z-INDEX: 108; LEFT: 24px;
POSITION: absolute; TOP: 352px"
Can I not return a table in a class property??

"Patrice" wrote:

> What I don't understand for now is the result you have.
> Do you mean you have no HTML at all rendered for this table ?
> If yes, it's likely this control is not part of the page.
> Do you mean you have rows missing ? What if you show the rows count to see
> if it's what you expect ?
> If not it's likely rows are not added in the collection...
> Etc...
> Some basic code would be :
> System.Web.UI.WebControls.Table TestFunction()
> {
> System.Web.UI.WebControls.Table t=new System.Web.UI.WebControls.Table();
> System.Web.UI.WebControls.TableRow r=new
> System.Web.UI.WebControls.TableRow();
> System.Web.UI.WebControls.TableCell c=new
> System.Web.UI.WebControls.TableCell();
> r.Cells.Add(c);
> t.Rows.Add(r);
> return t;
> }
> void Page_Load(Object sender,System.EventArgs e)
> {
> Form1.Controls.Add(TestFunction());
> }
> (use "view source" in your browser to see that it renders an empty HTML
> table).
> Hope it helps...
> Patrice
> --
> "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> > The table in the webpage is set to the returned table from the custom
> class
> > function. I know that there's data rows and cells in it.
> > on webpage:
> > objBusLog.FillTable(); //this is call to define the table
> > TblRpt = objBusLog.TblReports; //This sets table web control to actual
> > table being set in custom class.
> > ??
> > "Patrice" wrote:
> > > What do you mean by "Not reading the table properly". If collections are
> > > empty could it be you forgotten to add them asd they are created to your
> > > table ?
> > > > Patrice
> > > > --
> > > > "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> > > news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> > > > I'm wondering what the best way to do the following:
> > > > I have a page with a table. I built a custom class that creates a
> > > > System.Web.UI.WebControls table object and return it to the webpage as
> a
> > > > property. But its not reading the table correctly. It doesnt see the
> > > > tablerows and tablecell objects.
> > > > First, I'm not sure why its not reading the table properly?
> > > > Second, I wonder if there's a better way to do this? Maybe a custom
> > > control?
> > > > I haven't really gotten into these yet. My table only contains some
> > > > hyperlinks to open other pages. so no other server-side processing
> after
> > > > this.
> > > >
It looks like to me you are assigning TblRpts a *new* object and that you
would expect this new object to be rendered.

Actually behind the scene this object is registered in the "Controls"
collection before your code runs. As a result, assigning a *new* object to
this object variable won't have any effect (keep in mind that objects
variables are nothing else than "pointers").

I see basically two solutions :
- add the *new* control to the controls collection (and you don't need to
have the TblRpts controls in your page)
- pass TblRpts to your function so that you can add rows to the existing
control rather than creating a new one

Hope it helps...

Patrice

--

"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:E71CE228-7F0F-4182-8BDE-B43EA076A25C@.microsoft.com...
> Yes, the table is indeed a server side control. If I run the code directly
in
> the page_load, to build the table, all is good, like the way, your test
> function is setup..
> But in my case, I create a new class that creates the table. Then I get a
> property as follows:
> public System.Web.UI.WebControls.Table TblReports
> {
> get
> {
> return m_objTblRpts;
> }
> } }
> When I print the number of rows in the web page, it comes back as 2. But
it
> doesnt actually print the rows of the table. It only prints the following:
> <table id="TblRpts" border="0" style="width:928px;Z-INDEX: 108; LEFT:
24px;
> POSITION: absolute; TOP: 352px">
> Can I not return a table in a class property??
>
> "Patrice" wrote:
> > What I don't understand for now is the result you have.
> > Do you mean you have no HTML at all rendered for this table ?
> > If yes, it's likely this control is not part of the page.
> > Do you mean you have rows missing ? What if you show the rows count to
see
> > if it's what you expect ?
> > If not it's likely rows are not added in the collection...
> > Etc...
> > Some basic code would be :
> > System.Web.UI.WebControls.Table TestFunction()
> > {
> > System.Web.UI.WebControls.Table t=new
System.Web.UI.WebControls.Table();
> > System.Web.UI.WebControls.TableRow r=new
> > System.Web.UI.WebControls.TableRow();
> > System.Web.UI.WebControls.TableCell c=new
> > System.Web.UI.WebControls.TableCell();
> > r.Cells.Add(c);
> > t.Rows.Add(r);
> > return t;
> > }
> > void Page_Load(Object sender,System.EventArgs e)
> > {
> > Form1.Controls.Add(TestFunction());
> > }
> > (use "view source" in your browser to see that it renders an empty HTML
> > table).
> > Hope it helps...
> > Patrice
> > --
> > "klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
> > news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> > > The table in the webpage is set to the returned table from the custom
> > class
> > > function. I know that there's data rows and cells in it.
> > > on webpage:
> > > objBusLog.FillTable(); //this is call to define the table
> > > TblRpt = objBusLog.TblReports; //This sets table web control to
actual
> > > table being set in custom class.
> > > > ??
> > > > "Patrice" wrote:
> > > > > What do you mean by "Not reading the table properly". If collections
are
> > > > empty could it be you forgotten to add them asd they are created to
your
> > > > table ?
> > > > > > Patrice
> > > > > > --
> > > > > > "klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
> > > > news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> > > > > I'm wondering what the best way to do the following:
> > > > > I have a page with a table. I built a custom class that creates a
> > > > > System.Web.UI.WebControls table object and return it to the
webpage as
> > a
> > > > > property. But its not reading the table correctly. It doesnt see
the
> > > > > tablerows and tablecell objects.
> > > > > First, I'm not sure why its not reading the table properly?
> > > > > Second, I wonder if there's a better way to do this? Maybe a
custom
> > > > control?
> > > > > I haven't really gotten into these yet. My table only contains
some
> > > > > hyperlinks to open other pages. so no other server-side processing
> > after
> > > > > this.
> > > > > >
Thanks. That was it!
Appreciate it.

That leads back to the first question:
I'm trying to do this using a fairly good 'object-oriented' methodology. So
creating a new class to build a table, and return the table.. Is that the
best method?

"Patrice" wrote:

> It looks like to me you are assigning TblRpts a *new* object and that you
> would expect this new object to be rendered.
> Actually behind the scene this object is registered in the "Controls"
> collection before your code runs. As a result, assigning a *new* object to
> this object variable won't have any effect (keep in mind that objects
> variables are nothing else than "pointers").
> I see basically two solutions :
> - add the *new* control to the controls collection (and you don't need to
> have the TblRpts controls in your page)
> - pass TblRpts to your function so that you can add rows to the existing
> control rather than creating a new one
> Hope it helps...
> Patrice
> --
> "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> news:E71CE228-7F0F-4182-8BDE-B43EA076A25C@.microsoft.com...
> > Yes, the table is indeed a server side control. If I run the code directly
> in
> > the page_load, to build the table, all is good, like the way, your test
> > function is setup..
> > But in my case, I create a new class that creates the table. Then I get a
> > property as follows:
> > public System.Web.UI.WebControls.Table TblReports
> > {
> > get
> > {
> > return m_objTblRpts;
> > }
> > } }
> > When I print the number of rows in the web page, it comes back as 2. But
> it
> > doesnt actually print the rows of the table. It only prints the following:
> > <table id="TblRpts" border="0" style="width:928px;Z-INDEX: 108; LEFT:
> 24px;
> > POSITION: absolute; TOP: 352px">
> > Can I not return a table in a class property??
> > "Patrice" wrote:
> > > What I don't understand for now is the result you have.
> > > > Do you mean you have no HTML at all rendered for this table ?
> > > If yes, it's likely this control is not part of the page.
> > > > Do you mean you have rows missing ? What if you show the rows count to
> see
> > > if it's what you expect ?
> > > If not it's likely rows are not added in the collection...
> > > > Etc...
> > > > Some basic code would be :
> > > > System.Web.UI.WebControls.Table TestFunction()
> > > {
> > > System.Web.UI.WebControls.Table t=new
> System.Web.UI.WebControls.Table();
> > > System.Web.UI.WebControls.TableRow r=new
> > > System.Web.UI.WebControls.TableRow();
> > > System.Web.UI.WebControls.TableCell c=new
> > > System.Web.UI.WebControls.TableCell();
> > > r.Cells.Add(c);
> > > t.Rows.Add(r);
> > > return t;
> > > }
> > > void Page_Load(Object sender,System.EventArgs e)
> > > {
> > > Form1.Controls.Add(TestFunction());
> > > }
> > > > (use "view source" in your browser to see that it renders an empty HTML
> > > table).
> > > > Hope it helps...
> > > > Patrice
> > > > --
> > > > "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> > > news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> > > > The table in the webpage is set to the returned table from the custom
> > > class
> > > > function. I know that there's data rows and cells in it.
> > > > on webpage:
> > > > objBusLog.FillTable(); //this is call to define the table
> > > > TblRpt = objBusLog.TblReports; //This sets table web control to
> actual
> > > > table being set in custom class.
> > > > > > ??
> > > > > > "Patrice" wrote:
> > > > > > > What do you mean by "Not reading the table properly". If collections
> are
> > > > > empty could it be you forgotten to add them asd they are created to
> your
> > > > > table ?
> > > > > > > > Patrice
> > > > > > > > --
> > > > > > > > "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> > > > > news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> > > > > > I'm wondering what the best way to do the following:
> > > > > > I have a page with a table. I built a custom class that creates a
> > > > > > System.Web.UI.WebControls table object and return it to the
> webpage as
> > > a
> > > > > > property. But its not reading the table correctly. It doesnt see
> the
> > > > > > tablerows and tablecell objects.
> > > > > > First, I'm not sure why its not reading the table properly?
> > > > > > Second, I wonder if there's a better way to do this? Maybe a
> custom
> > > > > control?
> > > > > > I haven't really gotten into these yet. My table only contains
> some
> > > > > > hyperlinks to open other pages. so no other server-side processing
> > > after
> > > > > > this.
> > > > > > > > > > > > >
Depending on what it does you could create a control (in particular it
allows if applicable to provide some design time support).
You could also expose this a as "static" function depending on wether or not
it contains a state...

The key point is IMO to keep each part in its own layer and only using well
defined interactions with other parts, not doing things "OO" for its own
sake. As long as you do this, it will be easier to evolve each part
separately...

Patrice

--

"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:F7D8AB59-FDC8-4BFB-8851-D22FD6EDBC03@.microsoft.com...
> Thanks. That was it!
> Appreciate it.
> That leads back to the first question:
> I'm trying to do this using a fairly good 'object-oriented' methodology.
So
> creating a new class to build a table, and return the table.. Is that the
> best method?
> "Patrice" wrote:
> > It looks like to me you are assigning TblRpts a *new* object and that
you
> > would expect this new object to be rendered.
> > Actually behind the scene this object is registered in the "Controls"
> > collection before your code runs. As a result, assigning a *new* object
to
> > this object variable won't have any effect (keep in mind that objects
> > variables are nothing else than "pointers").
> > I see basically two solutions :
> > - add the *new* control to the controls collection (and you don't need
to
> > have the TblRpts controls in your page)
> > - pass TblRpts to your function so that you can add rows to the existing
> > control rather than creating a new one
> > Hope it helps...
> > Patrice
> > --
> > "klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
> > news:E71CE228-7F0F-4182-8BDE-B43EA076A25C@.microsoft.com...
> > > Yes, the table is indeed a server side control. If I run the code
directly
> > in
> > > the page_load, to build the table, all is good, like the way, your
test
> > > function is setup..
> > > > But in my case, I create a new class that creates the table. Then I
get a
> > > property as follows:
> > > public System.Web.UI.WebControls.Table TblReports
> > > {
> > > get
> > > {
> > > return m_objTblRpts;
> > > }
> > > } }
> > > When I print the number of rows in the web page, it comes back as 2.
But
> > it
> > > doesnt actually print the rows of the table. It only prints the
following:
> > > <table id="TblRpts" border="0" style="width:928px;Z-INDEX: 108; LEFT:
> > 24px;
> > > POSITION: absolute; TOP: 352px">
> > > > Can I not return a table in a class property??
> > > > > "Patrice" wrote:
> > > > > What I don't understand for now is the result you have.
> > > > > > Do you mean you have no HTML at all rendered for this table ?
> > > > If yes, it's likely this control is not part of the page.
> > > > > > Do you mean you have rows missing ? What if you show the rows count
to
> > see
> > > > if it's what you expect ?
> > > > If not it's likely rows are not added in the collection...
> > > > > > Etc...
> > > > > > Some basic code would be :
> > > > > > System.Web.UI.WebControls.Table TestFunction()
> > > > {
> > > > System.Web.UI.WebControls.Table t=new
> > System.Web.UI.WebControls.Table();
> > > > System.Web.UI.WebControls.TableRow r=new
> > > > System.Web.UI.WebControls.TableRow();
> > > > System.Web.UI.WebControls.TableCell c=new
> > > > System.Web.UI.WebControls.TableCell();
> > > > r.Cells.Add(c);
> > > > t.Rows.Add(r);
> > > > return t;
> > > > }
> > > > void Page_Load(Object sender,System.EventArgs e)
> > > > {
> > > > Form1.Controls.Add(TestFunction());
> > > > }
> > > > > > (use "view source" in your browser to see that it renders an empty
HTML
> > > > table).
> > > > > > Hope it helps...
> > > > > > Patrice
> > > > > > --
> > > > > > "klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
> > > > news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> > > > > The table in the webpage is set to the returned table from the
custom
> > > > class
> > > > > function. I know that there's data rows and cells in it.
> > > > > on webpage:
> > > > > objBusLog.FillTable(); //this is call to define the table
> > > > > TblRpt = objBusLog.TblReports; //This sets table web control to
> > actual
> > > > > table being set in custom class.
> > > > > > > > ??
> > > > > > > > "Patrice" wrote:
> > > > > > > > > What do you mean by "Not reading the table properly". If
collections
> > are
> > > > > > empty could it be you forgotten to add them asd they are created
to
> > your
> > > > > > table ?
> > > > > > > > > > Patrice
> > > > > > > > > > --
> > > > > > > > > > "klynn" <klynn@.discussions.microsoft.com> a crit dans le
message de
> > > > > > news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> > > > > > > I'm wondering what the best way to do the following:
> > > > > > > I have a page with a table. I built a custom class that
creates a
> > > > > > > System.Web.UI.WebControls table object and return it to the
> > webpage as
> > > > a
> > > > > > > property. But its not reading the table correctly. It doesnt
see
> > the
> > > > > > > tablerows and tablecell objects.
> > > > > > > First, I'm not sure why its not reading the table properly?
> > > > > > > Second, I wonder if there's a better way to do this? Maybe a
> > custom
> > > > > > control?
> > > > > > > I haven't really gotten into these yet. My table only contains
> > some
> > > > > > > hyperlinks to open other pages. so no other server-side
processing
> > > > after
> > > > > > > this.
> > > > > > > > > > > > > > > > > >

pass table back to webpage

I'm wondering what the best way to do the following:
I have a page with a table. I built a custom class that creates a
System.Web.UI.WebControls table object and return it to the webpage as a
property. But its not reading the table correctly. It doesnt see the
tablerows and tablecell objects.
First, I'm not sure why its not reading the table properly?
Second, I wonder if there's a better way to do this? Maybe a custom control?
I haven't really gotten into these yet. My table only contains some
hyperlinks to open other pages. so no other server-side processing after
this.What do you mean by "Not reading the table properly". If collections are
empty could it be you forgotten to add them asd they are created to your
table ?
Patrice
"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> I'm wondering what the best way to do the following:
> I have a page with a table. I built a custom class that creates a
> System.Web.UI.WebControls table object and return it to the webpage as a
> property. But its not reading the table correctly. It doesnt see the
> tablerows and tablecell objects.
> First, I'm not sure why its not reading the table properly?
> Second, I wonder if there's a better way to do this? Maybe a custom
control?
> I haven't really gotten into these yet. My table only contains some
> hyperlinks to open other pages. so no other server-side processing after
> this.
The table in the webpage is set to the returned table from the custom class
function. I know that there's data rows and cells in it.
on webpage:
objBusLog.FillTable(); //this is call to define the table
TblRpt = objBusLog.TblReports; //This sets table web control to actual
table being set in custom class.
'
"Patrice" wrote:

> What do you mean by "Not reading the table properly". If collections are
> empty could it be you forgotten to add them asd they are created to your
> table ?
> Patrice
> --
> "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> news:77A30CE6-FBD4-4591-A6C6-9D3FB1015117@.microsoft.com...
> control?
>
>
What I don't understand for now is the result you have.
Do you mean you have no HTML at all rendered for this table ?
If yes, it's likely this control is not part of the page.
Do you mean you have rows missing ? What if you show the rows count to see
if it's what you expect ?
If not it's likely rows are not added in the collection...
Etc...
Some basic code would be :
System.Web.UI.WebControls.Table TestFunction()
{
System.Web.UI.WebControls.Table t=new System.Web.UI.WebControls.Table();
System.Web.UI.WebControls.TableRow r=new
System.Web.UI.WebControls.TableRow();
System.Web.UI.WebControls.TableCell c=new
System.Web.UI.WebControls.TableCell();
r.Cells.Add(c);
t.Rows.Add(r);
return t;
}
void Page_Load(Object sender,System.EventArgs e)
{
Form1.Controls.Add(TestFunction());
}
(use "view source" in your browser to see that it renders an empty HTML
table).
Hope it helps...
Patrice
"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> The table in the webpage is set to the returned table from the custom
class
> function. I know that there's data rows and cells in it.
> on webpage:
> objBusLog.FillTable(); //this is call to define the table
> TblRpt = objBusLog.TblReports; //This sets table web control to actual
> table being set in custom class.
> '
> "Patrice" wrote:
>
a
after
Yes, the table is indeed a server side control. If I run the code directly i
n
the page_load, to build the table, all is good, like the way, your test
function is setup..
But in my case, I create a new class that creates the table. Then I get a
property as follows:
public System.Web.UI.WebControls.Table TblReports
{
get
{
return m_objTblRpts;
}
} }
When I print the number of rows in the web page, it comes back as 2. But it
doesnt actually print the rows of the table. It only prints the following:
<table id="TblRpts" border="0" style="width:928px;Z-INDEX: 108; LEFT: 24px;
POSITION: absolute; TOP: 352px">
Can I not return a table in a class property'
"Patrice" wrote:

> What I don't understand for now is the result you have.
> Do you mean you have no HTML at all rendered for this table ?
> If yes, it's likely this control is not part of the page.
> Do you mean you have rows missing ? What if you show the rows count to see
> if it's what you expect ?
> If not it's likely rows are not added in the collection...
> Etc...
> Some basic code would be :
> System.Web.UI.WebControls.Table TestFunction()
> {
> System.Web.UI.WebControls.Table t=new System.Web.UI.WebControls.Table();
> System.Web.UI.WebControls.TableRow r=new
> System.Web.UI.WebControls.TableRow();
> System.Web.UI.WebControls.TableCell c=new
> System.Web.UI.WebControls.TableCell();
> r.Cells.Add(c);
> t.Rows.Add(r);
> return t;
> }
> void Page_Load(Object sender,System.EventArgs e)
> {
> Form1.Controls.Add(TestFunction());
> }
> (use "view source" in your browser to see that it renders an empty HTML
> table).
> Hope it helps...
> Patrice
> --
> "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> news:E7684476-F77A-4077-9DEF-71C88810280C@.microsoft.com...
> class
> a
> after
>
>
It looks like to me you are assigning TblRpts a *new* object and that you
would expect this new object to be rendered.
Actually behind the scene this object is registered in the "Controls"
collection before your code runs. As a result, assigning a *new* object to
this object variable won't have any effect (keep in mind that objects
variables are nothing else than "pointers").
I see basically two solutions :
- add the *new* control to the controls collection (and you don't need to
have the TblRpts controls in your page)
- pass TblRpts to your function so that you can add rows to the existing
control rather than creating a new one
Hope it helps...
Patrice
"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:E71CE228-7F0F-4182-8BDE-B43EA076A25C@.microsoft.com...
> Yes, the table is indeed a server side control. If I run the code directly
in
> the page_load, to build the table, all is good, like the way, your test
> function is setup..
> But in my case, I create a new class that creates the table. Then I get a
> property as follows:
> public System.Web.UI.WebControls.Table TblReports
> {
> get
> {
> return m_objTblRpts;
> }
> } }
> When I print the number of rows in the web page, it comes back as 2. But
it
> doesnt actually print the rows of the table. It only prints the following:
> <table id="TblRpts" border="0" style="width:928px;Z-INDEX: 108; LEFT:
24px;
> POSITION: absolute; TOP: 352px">
> Can I not return a table in a class property'
>
> "Patrice" wrote:
>
see
System.Web.UI.WebControls.Table();
actual
are
your
webpage as
the
custom
some
Thanks. That was it!
Appreciate it.
That leads back to the first question:
I'm trying to do this using a fairly good 'object-oriented' methodology. So
creating a new class to build a table, and return the table.. Is that the
best method?
"Patrice" wrote:

> It looks like to me you are assigning TblRpts a *new* object and that you
> would expect this new object to be rendered.
> Actually behind the scene this object is registered in the "Controls"
> collection before your code runs. As a result, assigning a *new* object to
> this object variable won't have any effect (keep in mind that objects
> variables are nothing else than "pointers").
> I see basically two solutions :
> - add the *new* control to the controls collection (and you don't need to
> have the TblRpts controls in your page)
> - pass TblRpts to your function so that you can add rows to the existing
> control rather than creating a new one
> Hope it helps...
> Patrice
> --
> "klynn" <klynn@.discussions.microsoft.com> a écrit dans le message de
> news:E71CE228-7F0F-4182-8BDE-B43EA076A25C@.microsoft.com...
> in
> it
> 24px;
> see
> System.Web.UI.WebControls.Table();
> actual
> are
> your
> webpage as
> the
> custom
> some
>
>
Depending on what it does you could create a control (in particular it
allows if applicable to provide some design time support).
You could also expose this a as "static" function depending on wether or not
it contains a state...
The key point is IMO to keep each part in its own layer and only using well
defined interactions with other parts, not doing things "OO" for its own
sake. As long as you do this, it will be easier to evolve each part
separately...
Patrice
"klynn" <klynn@.discussions.microsoft.com> a crit dans le message de
news:F7D8AB59-FDC8-4BFB-8851-D22FD6EDBC03@.microsoft.com...
> Thanks. That was it!
> Appreciate it.
> That leads back to the first question:
> I'm trying to do this using a fairly good 'object-oriented' methodology.
So
> creating a new class to build a table, and return the table.. Is that the
> best method?
> "Patrice" wrote:
>
you
to
to
directly
test
get a
But
following:
to
HTML
custom
collections
to
message de
creates a
see
processing

Pass value from javascript to vb.net to database without postback...Possible?

Hi,
I have a complicated question that I'm hoping someone can help me out
with. I have a webpage that contains a plug-in. This plug-in can
communicate/pass data with the webpage that contains it via javascript.
What I need to be able to do is take that data passed via javascript
and, using vb.net as the code behind language, send it to a database
without posting it because when I post, the plugin is reloaded and
starts at the beginning. Specifcally, the plug-in is a type of
educational program, when the user completes a certain objective in the
program, I need to store that info in the database but not have the
program start back at the beginning.
What happens currently is upon completing the objective in the plugin,
a javascript function is called in the containing webpage. That
javascript function changes the data in a hidden field runat the
server. I artificially create a postback using the
document.forms.submit() function, then in the page_load function in the
codebehind page I check the value of the hidden field and store it to
the database. This works fine. The problem is that when the page
reloads, my plug-in is reloaded and instead of the user being at say
level 6, they are back at the initial level 1. Ideally, I would like to
send the information to the database without having to reload the page
and was wondering if this was possible.
Thanks in advance and I'll be happy to clarify any questions.
AndyYou would need to do something like use XMLHTTP to issue a call to a page to
do the work. However, I think that ties you to IE 5.5 and above. This may
or may not be a problem for you.
"Andy" <acs974@.hotmail.com> wrote in message
news:1129749048.607189.307420@.g44g2000cwa.googlegroups.com...
> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
>
the easiest approach is a hidden iframe/frame.
1) the src of the hidden frame should be an aspx page with hidden fields.
the clientscript would fill in the hidden fields in the frame, and do a
submit of the frame.
2) create an addtional form (nonserver) on the page with the target the
hidden frame, have the client script fill in the hidden fields in the form
and do a submit.
-- bruce (sqlwork.com)
"Andy" <acs974@.hotmail.com> wrote in message
news:1129749048.607189.307420@.g44g2000cwa.googlegroups.com...
> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
>
Once you're upgraded to ASP.NET 2.0 you can use the new client side
callback feature to do this kind of thing.
Here's more info:
http://www.aspnetpro.com/features/2...p200511so_f.asp
http://www.developer.com/net/asp/article.php/3506896
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Andy" <acs974@.hotmail.com> wrote in message
news:1129749048.607189.307420@.g44g2000cwa.googlegroups.com...
> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
>
if you don't need anything back, it's trivial:
var sender = new Image();
sender.src = "whatever.aspx?stufff=1&junkID=27";
Done, and done.
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/
Thanks everyone for their help. It seems that ajax is probably going to
be the way I go. I tried to avoid it since I'm pretty new to this web
programming and didn't understand if it was for me, but it seems that's
what I need long term. One quick question, I've been using asp.net 2.0
but because it is in its beta form, I have avoided exploiting much of
its newer features. How worried do I have to be about creating a
website in 2.0 beta then having it not work on me when the final
release comes out?

Pass value from javascript to vb.net to database without postback...Possible?

Hi,

I have a complicated question that I'm hoping someone can help me out
with. I have a webpage that contains a plug-in. This plug-in can
communicate/pass data with the webpage that contains it via javascript.
What I need to be able to do is take that data passed via javascript
and, using vb.net as the code behind language, send it to a database
without posting it because when I post, the plugin is reloaded and
starts at the beginning. Specifcally, the plug-in is a type of
educational program, when the user completes a certain objective in the
program, I need to store that info in the database but not have the
program start back at the beginning.

What happens currently is upon completing the objective in the plugin,
a javascript function is called in the containing webpage. That
javascript function changes the data in a hidden field runat the
server. I artificially create a postback using the
document.forms.submit() function, then in the page_load function in the
codebehind page I check the value of the hidden field and store it to
the database. This works fine. The problem is that when the page
reloads, my plug-in is reloaded and instead of the user being at say
level 6, they are back at the initial level 1. Ideally, I would like to
send the information to the database without having to reload the page
and was wondering if this was possible.

Thanks in advance and I'll be happy to clarify any questions.

AndyYou would need to do something like use XMLHTTP to issue a call to a page to
do the work. However, I think that ties you to IE 5.5 and above. This may
or may not be a problem for you.

"Andy" <acs974@.hotmail.com> wrote in message
news:1129749048.607189.307420@.g44g2000cwa.googlegr oups.com...
> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
Look at AJAX.net
It may take care of your needs in this case.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Andy" wrote:

> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
>
the easiest approach is a hidden iframe/frame.

1) the src of the hidden frame should be an aspx page with hidden fields.
the clientscript would fill in the hidden fields in the frame, and do a
submit of the frame.

2) create an addtional form (nonserver) on the page with the target the
hidden frame, have the client script fill in the hidden fields in the form
and do a submit.

-- bruce (sqlwork.com)

"Andy" <acs974@.hotmail.com> wrote in message
news:1129749048.607189.307420@.g44g2000cwa.googlegr oups.com...
> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
Once you're upgraded to ASP.NET 2.0 you can use the cool new client side
callback feature to do this kind of thing.

Here's more info:
http://www.aspnetpro.com/features/2...p200511so_f.asp
http://www.developer.com/net/asp/article.php/3506896

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Andy" <acs974@.hotmail.com> wrote in message
news:1129749048.607189.307420@.g44g2000cwa.googlegr oups.com...
> Hi,
> I have a complicated question that I'm hoping someone can help me out
> with. I have a webpage that contains a plug-in. This plug-in can
> communicate/pass data with the webpage that contains it via javascript.
> What I need to be able to do is take that data passed via javascript
> and, using vb.net as the code behind language, send it to a database
> without posting it because when I post, the plugin is reloaded and
> starts at the beginning. Specifcally, the plug-in is a type of
> educational program, when the user completes a certain objective in the
> program, I need to store that info in the database but not have the
> program start back at the beginning.
> What happens currently is upon completing the objective in the plugin,
> a javascript function is called in the containing webpage. That
> javascript function changes the data in a hidden field runat the
> server. I artificially create a postback using the
> document.forms.submit() function, then in the page_load function in the
> codebehind page I check the value of the hidden field and store it to
> the database. This works fine. The problem is that when the page
> reloads, my plug-in is reloaded and instead of the user being at say
> level 6, they are back at the initial level 1. Ideally, I would like to
> send the information to the database without having to reload the page
> and was wondering if this was possible.
> Thanks in advance and I'll be happy to clarify any questions.
> Andy
if you don't need anything back, it's trivial:

var sender = new Image();
sender.src = "whatever.aspx?stufff=1&junkID=27";

Done, and done.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

--
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/
Thanks everyone for their help. It seems that ajax is probably going to
be the way I go. I tried to avoid it since I'm pretty new to this web
programming and didn't understand if it was for me, but it seems that's
what I need long term. One quick question, I've been using asp.net 2.0
but because it is in its beta form, I have avoided exploiting much of
its newer features. How worried do I have to be about creating a
website in 2.0 beta then having it not work on me when the final
release comes out?
Be very worried! Well, not to scare you or anything but seriously, any new
product in beta is not going to be 100% reliable. That's why they call it
alpha, beta.
That being said, you can do a search on google for a list of issues in beta,
that way you can be aware of what's going to work on final release.

"Andy" wrote:

> Thanks everyone for their help. It seems that ajax is probably going to
> be the way I go. I tried to avoid it since I'm pretty new to this web
> programming and didn't understand if it was for me, but it seems that's
> what I need long term. One quick question, I've been using asp.net 2.0
> but because it is in its beta form, I have avoided exploiting much of
> its newer features. How worried do I have to be about creating a
> website in 2.0 beta then having it not work on me when the final
> release comes out?
>

Saturday, March 24, 2012

pass variable between webpage

I want to ask what is the best way to pass variable between asp.net we
pages, and user controls , any examples

-
dolla
----------------------
Posted via http://www.codecomments.co
----------------------Hi Dollar,

There are various ways in which ASP.NET helps you to pass information
from one page to another, it basically depends on your application.
In general, the applications use Session state to pass variables.

You can refer to the following link for complete details:

[State Management Recommendations]
http://msdn.microsoft.com/library/d...StateOption.asp

As for user controls, you can have public properties for the user control
which can be accessed by any page and also they will retain their values in
between
server round trips.

HTH

Mona[Grapecity]

"dollar" <dollar.1pp11p@.mail.codecomments.com> wrote in message
news:dollar.1pp11p@.mail.codecomments.com...
> I want to ask what is the best way to pass variable between asp.net web
> pages, and user controls , any examples?
>
> --
> dollar
> ----------------------
> Posted via http://www.codecomments.com
> ----------------------

pass variable between webpage

I want to ask what is the best way to pass variable between asp.net web page
s, and user controls , any examples?Hi Dollar,
There are various ways in which ASP.NET helps you to pass information
from one page to another, it basically depends on your application.
In general, the applications use Session state to pass variables.
You can refer to the following link for complete details:
[State Management Recommendations]
http://msdn.microsoft.com/library/d...StateOption.asp
As for user controls, you can have public properties for the user control
which can be accessed by any page and also they will retain their values in
between
server round trips.
HTH
Mona[Grapecity]
"dollar" <dollar.1pp11p@.mail.codecomments.com> wrote in message
news:dollar.1pp11p@.mail.codecomments.com...
> I want to ask what is the best way to pass variable between asp.net web
> pages, and user controls , any examples?
>
> --
> dollar
> ---
> Posted via http://www.codecomments.com
> ---
>