Thursday, March 29, 2012
Pass information from XML file to ASPX page
I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?
Thanks in advance for help,
uservoidHi evangelous,
Maybe this can help you:
http://www.planet-source-code.com/v...gWId=10
Guillermo G.
----
--
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4
<evangelous@.gmail.com> wrote in message news:1122017876.519551.161420@.g49g20
00cwa.googlegroups.com...
Hello,
I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?
Thanks in advance for help,
uservoid
Pass information from XML file to ASPX page
I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?
Thanks in advance for help,
uservoidHi evangelous,
Maybe this can help you:
http://www.planet-source-code.com/v...=3753&lngWId=10
Guillermo G.
------------------------
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4
<evangelous@.gmail.com> wrote in message news:1122017876.519551.161420@.g49g2000cwa.googlegr oups.com...
Hello,
I have an XML file, which contains let's say a <A> tag with a "AProp"
property. I want to manipulate this XML file so that the value of the
AProp property can be passed to the code-behind class (let's say
code.aspx.cs) of another ASPX page. How can I accomplish that?
Thanks in advance for help,
uservoid
Pass message
Dear,
Please let me know about querystring or howevery u know.Im tyring to pass one message one aspx page to second aspx page how can i make sentence.plz write down for me with example
This may help:
http://msdn.microsoft.com/msdnmag/issues/07/03/CuttingEdge/default.aspx?loc=en
http://www.codeproject.com/aspnet/QueryString.asp
http://www.eggheadcafe.com/articles/20060427.asp
I hope it helps. Regards,
Check below my blog post
Ways to pass data between webforms
HC
pass multiple values from one aspx page to another
have in the first page are:
a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
It is a search page, and the users need not enter values in all the
controls. they can leave the textbox blank, and select values from one
drop down, or any other combinations.
I am trying to pass values with the help of session variables. But I
have multiple if else statements like:
if (ddlCategories.SelectedItem.Value == "")
{
Session["CatID"] = "";
}
else
{
Session["CatID"] = ddlCategories.SelectedItem.Value;
}
The value in the second drop down depends on the value in the first,
and the value in the third drop down depends on the second drop down.
So, its giving me an error saying "Object reference not set to an
instance of the object" if I don't select any value from the first drop
down .(same is the case for the second drop down).
What is the best way yo do this? without all the if else statements,
and may be without using the session variables.
any suggestions?Regarding your object reference error...
You could check for the existance of a selected item first, before trying to
read its value, e.g.
Session["CatID"] = "";
if (ddlCategories.SelectedItem != null)
Session["CatID"] = ddlCategories.SelectedItem.Value;
However I think that there may be a shortcut approach using
ddlCategories.SelectedValue instead. I haven't tested this property without
a selected item, but it will probably return null rather than an exception.
Worth exploring. If it works for you, you may be able to simplify the
constructs to, e.g.;
Session["CatID"] = ddlCategories.SelectedItem.Value;
... with no safety check. If you need to treat "" and null the same (and
have "" as values in your list), you can write a helper function as in;
Session["CatID"] = MakeEmptyStringNull (ddlCategories.SelectedItem.Value);
Regarding your value-passing approach, session variables work fine but makes
the receiving page limited. I prefer to put essentially all navigation
rules into the Url so that users can bookmark search pages reliably, forward
the Url to friends, etc. The cleanest way I've found to do this is to
construct a class that manages the navigation to the target page, and
formulates the Url based on properties, e.g.
class SearchPageUrl
{
public string CatID;
public string Option1;
public string Option2;
/// Generate the Url
public override string ToString ()
{
return String.Format (
"/search/results.aspx?CatID={0}&Option1={1}&Option2={2}",
CatID, Option1, Option2
);
}
/// Determine whether the necessary properties have been set to generate
a valid Url
public bool IsValidUrl ()
{
return true;
}
}
in your onclick;
SearchPageUrl sup = new SearchPageUrl ();
sup.CatID = ddlCategories.SelectedValue;
sup.Option1 = ... ;
sup.Option2 = ... ;
if (sup.IsValidUrl())
Response.Redirect (sup.ToString ());
else
// show error
In your receiving page, you can simplify the querystring processing through
page-level properties, e.g.;
private bool HasCatID
{
get { return Request["CatID"] != null; }
}
private int CatID
{
get { return Int32.Parse (Request["CatID"]); }
}
Which keeps the code in your page clean, and centralizes the parsing of your
querystring propeties.
Clearly this is a bit more code than the Session var approach but it's worth
considering. Most users expect the pages to be bookmarkable.
/// M
"macyp" <vradhika@.gmail.com> wrote in message
news:1106755384.274484.211140@.c13g2000cwb.googlegroups.com...
> I have to pass values from one aspx page to another. The controls I
> have in the first page are:
> a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
> It is a search page, and the users need not enter values in all the
> controls. they can leave the textbox blank, and select values from one
> drop down, or any other combinations.
> I am trying to pass values with the help of session variables. But I
> have multiple if else statements like:
> if (ddlCategories.SelectedItem.Value == "")
> {
> Session["CatID"] = "";
> }
> else
> {
> Session["CatID"] = ddlCategories.SelectedItem.Value;
> }
> The value in the second drop down depends on the value in the first,
> and the value in the third drop down depends on the second drop down.
> So, its giving me an error saying "Object reference not set to an
> instance of the object" if I don't select any value from the first drop
> down .(same is the case for the second drop down).
> What is the best way yo do this? without all the if else statements,
> and may be without using the session variables.
> any suggestions?
>
Hi Macyp,
Checking that the SelectedIndex DropDownList property is not equal to
-1 before retrieving the SelectedItem.Value property should solve your
"Object referenct" problem. Sample:
if (ddlCategories.SelectedIndex != -1)
Tod Birdsall
http://tod1d.blogspot.com
pass multiple values from one aspx page to another
have in the first page are:
a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
It is a search page, and the users need not enter values in all the
controls. they can leave the textbox blank, and select values from one
drop down, or any other combinations.
I am trying to pass values with the help of session variables. But I
have multiple if else statements like:
if (ddlCategories.SelectedItem.Value == "")
{
Session["CatID"] = "";
}
else
{
Session["CatID"] = ddlCategories.SelectedItem.Value;
}
The value in the second drop down depends on the value in the first,
and the value in the third drop down depends on the second drop down.
So, its giving me an error saying "Object reference not set to an
instance of the object" if I don't select any value from the first drop
down .(same is the case for the second drop down).
What is the best way yo do this? without all the if else statements,
and may be without using the session variables.
any suggestions?Regarding your object reference error...
You could check for the existance of a selected item first, before trying to
read its value, e.g.
Session["CatID"] = "";
if (ddlCategories.SelectedItem != null)
Session["CatID"] = ddlCategories.SelectedItem.Value;
However I think that there may be a shortcut approach using
ddlCategories.SelectedValue instead. I haven't tested this property without
a selected item, but it will probably return null rather than an exception.
Worth exploring. If it works for you, you may be able to simplify the
constructs to, e.g.;
Session["CatID"] = ddlCategories.SelectedItem.Value;
... with no safety check. If you need to treat "" and null the same (and
have "" as values in your list), you can write a helper function as in;
Session["CatID"] = MakeEmptyStringNull (ddlCategories.SelectedItem.Value);
Regarding your value-passing approach, session variables work fine but makes
the receiving page limited. I prefer to put essentially all navigation
rules into the Url so that users can bookmark search pages reliably, forward
the Url to friends, etc. The cleanest way I've found to do this is to
construct a class that manages the navigation to the target page, and
formulates the Url based on properties, e.g.
class SearchPageUrl
{
public string CatID;
public string Option1;
public string Option2;
/// Generate the Url
public override string ToString ()
{
return String.Format (
"/search/results.aspx?CatID={0}&Option1={1}&Option2={2}",
CatID, Option1, Option2
);
}
/// Determine whether the necessary properties have been set to generate
a valid Url
public bool IsValidUrl ()
{
return true;
}
}
in your onclick;
SearchPageUrl sup = new SearchPageUrl ();
sup.CatID = ddlCategories.SelectedValue;
sup.Option1 = ... ;
sup.Option2 = ... ;
if (sup.IsValidUrl())
Response.Redirect (sup.ToString ());
else
// show error
In your receiving page, you can simplify the querystring processing through
page-level properties, e.g.;
private bool HasCatID
{
get { return Request["CatID"] != null; }
}
private int CatID
{
get { return Int32.Parse (Request["CatID"]); }
}
Which keeps the code in your page clean, and centralizes the parsing of your
querystring propeties.
Clearly this is a bit more code than the Session var approach but it's worth
considering. Most users expect the pages to be bookmarkable.
/// M
"macyp" <vradhika@.gmail.com> wrote in message
news:1106755384.274484.211140@.c13g2000cwb.googlegr oups.com...
> I have to pass values from one aspx page to another. The controls I
> have in the first page are:
> a textbox, 3 drop down lists, and 2 check boxes, and a submit button.
> It is a search page, and the users need not enter values in all the
> controls. they can leave the textbox blank, and select values from one
> drop down, or any other combinations.
> I am trying to pass values with the help of session variables. But I
> have multiple if else statements like:
> if (ddlCategories.SelectedItem.Value == "")
> {
> Session["CatID"] = "";
> }
> else
> {
> Session["CatID"] = ddlCategories.SelectedItem.Value;
> }
> The value in the second drop down depends on the value in the first,
> and the value in the third drop down depends on the second drop down.
> So, its giving me an error saying "Object reference not set to an
> instance of the object" if I don't select any value from the first drop
> down .(same is the case for the second drop down).
> What is the best way yo do this? without all the if else statements,
> and may be without using the session variables.
> any suggestions?
Hi Macyp,
Checking that the SelectedIndex DropDownList property is not equal to
-1 before retrieving the SelectedItem.Value property should solve your
"Object referenct" problem. Sample:
if (ddlCategories.SelectedIndex != -1)
Tod Birdsall
http://tod1d.blogspot.com
Pass Object from one page to another
Hi, I have one page that has several methods that populate an ArrayList with data. I want to be able to pass this populated ArrayList to another page on the site. Is there any way that this can be done? I know values can be passed using the QueryString, but I need the whole ArrayList object to be passed.
Any help would be greatly appreciated.
Thanks
You can store it in a session variable:http://msdn2.microsoft.com/en-us/library/ms178581.aspx
From the page:
By default, session variables can be any valid .NET type. For example, the following code example stores anArrayListof values in a session variable named "StockPicks." Note that the valuereturned by the "StockPicks" session variable must be cast as theappropriate type upon retrieval from theSessionStateItemCollection.
1) You can keep the arraylist in the session object and can access the session object into another page.
2) You can make serializable class file and make the public object. By using context handler you can access the public object into another page.
Regards,
Suhas
Suhas.Chitade:
2) You can make serializable class file and make the public object. By using context handler you can access the public object into another page.
I've never tried this approach before. Would it mean that the same object is available to all users? Also, how long would the object persist?
Pass parameters through a hyperlink?
For Instance -- HTTP://WWW.MYDOMAIN.COM/PAGE.ASPX?VARIABLE=ABCD
And then if I reference VARIABLE in code, it will be equal to ABCD? If this is not possible directly as I described above, how can it be possible, because I need to somehow pass variables/parameters through a hyperlink.
I know about Session("") already, and that can pass data between pages, I know, but I need to do it through a hyperlink somehow.
Thanks.Sure, you can access it via the QueryString property of the Request object:
string var = Request.QueryString["VARIABLE"];
The string var now has the value of "ABCD".
Thanks a million, works great! :)
Hello
I need to pass parameter through a hyperlink but I don't know how to do this.
I try this in HTML
NavigateUrl="javascript:popup('AddNewContact.aspx?text="+BrokerName+"&BrokerKey="+BrokerID+"',500,700)
It did work.
Can you help me?
THanks,
Guarumal,
What you are doing is different than the original post. His is a static URL and you are building a dynamic URL. This should be a new thread.
My first question is, are BrokerName and BrokerKey VB/C# variables or javascript variables? The most likely situation is that you are trying to build the NavigateURL property in the wrong place. If those are VB/C# variables you need to do this in the code behind page.
Pass Parameters to Dynamically Loaded Control?
I have a page that dynamically loads a control:
Dim RelatedProductsControlAs Control =LoadControl("~/controls/RelatedProducts.ascx")
RelatedProductsPanel.Controls.Add(RelatedProductsControl)
That works perfectly but the problem is I need to set a Public Property in the control. I know you can pass partameters to the control like this:
LoadControl("~/controls/RelatedProducts.asx", Parameters As Object)
But I am not sure how the create the parameter as an object so that I can pass it? Any help would be greatly appreciated.
Thanks,
Max
Hi,
You can set the public properties of the control as:
Dim RelatedProductsControlAs Control = LoadControl("~/controls/RelatedProducts.ascx")
Ctype(RelatedProductsControl,Relatedproducts) 'here i am casting the control to its class
RelatedProductsControl.PropertyXXX = "something" 'now i can access the properties as i have casted it to the control class
RelatedProductsPanel.Controls.Add(RelatedProductsControl)
Hope this helps,
Vivek
I tried what you suggested and changed my code to this:
Dim RelatedProductsControlAs Control = LoadControl("~/controls/RelatedProducts.ascx")
CType(RelatedProductsControl, RelatedProducts)'here i am casting the control to its class
RelatedProductsControl.PricingEmail =True
RelatedProductsPanel.Controls.Add(RelatedProductsControl)
But I get an error 'Type RelatedProducts in not defined'
Surely I am missing something here?
Dim cAs WebUserControl =CType(LoadControl("~/controls/WebUsercontrol.ascx"), WebUserControl)
c.MySkin ="hj"
Now, this will work only if I can "access" the class WebUsercontrol.vb in my page's page_load. In your case it is giving an error because the control is incontrolsfolder, so unless you add a namespace in your page, or move the control outside of the Controls folder (in the same directory as the page), it will give this error.
HTH,
Vivek
BTW: you can avoid this "type XX not find" issue by creating a <%Register %> tag in your aspx page as:
<%@.RegisterSrc="controls/WebUserControl.ascx"TagName="WebUserControl"TagPrefix="uc1" %>
Just write this tag so that the Page is able to find the UserControl's class (since it is not in the same folder as the page).
But this is an issue when you do not know the name of the control to be created, and AFAIK there is no solution to it because the VS 2005 Website model uses multiple assemblies so using wihthout a common namespace. An alternative is to use Web Application project model (old one followed in VS 2003). You can get the same from:
http://weblogs.asp.net/scottgu/archive/2006/04/05/442032.aspx
Hope this helps,
Vivek
Thank You! Thank You! Thank You!
Your last suggestion worked perfectly and worked with my existing file structure - thanks again!
Pass parameters to User Control
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
--
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
Sorry for the delay in replying:
I have heard that you can use this method to pass the parameter:
<%@.Register tagprefix="CodeLib" Tagname="usrMain" src="http://pics.10026.com/?src=usrMain.ascx" %
<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/
But the problem is that I cannot seem to extract the data on the ASCX page
Thanks Ben
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:e$%23BiHkJEHA.3944@.tk2msftngp13.phx.gbl...
> For this purpose I used to create properties (in user control). This way
you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In
case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > Hi
> > I am using a User Control which is referenced by an ASPX page.
> > How can I pass a string parameter to the user control, from the base
ASPX
> > page.
> > Thanks
> > Ben
Help! I have an aspx that loads the ascx with parameters in a
placeholder as textboxes. On my postback I can't get the values out
of the textboxes. They are still on the screen so I'm sure they are
there.
I'm having a hard time. I've been told they should just be there.
aspx
ascx
ascxwp
The ascxwp is the user control that holds the textboxes.
I assume someone has figured this out. We have 3 asp programmers and
we are all stumped.
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
> For this purpose I used to create properties (in user control). This way you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > Hi
> > I am using a User Control which is referenced by an ASPX page.
> > How can I pass a string parameter to the user control, from the base ASPX
> > page.
> > Thanks
> > Ben
Implement Properties inside of your UserControl
e.g.
Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property
Then just access the properties
"Lynne K." <ltgaer@.assurity.com> wrote in message
news:7a65e5b4.0405110605.559f0d2d@.posting.google.c om...
> Help! I have an aspx that loads the ascx with parameters in a
> placeholder as textboxes. On my postback I can't get the values out
> of the textboxes. They are still on the screen so I'm sure they are
> there.
> I'm having a hard time. I've been told they should just be there.
> aspx
> ascx
> ascxwp
> The ascxwp is the user control that holds the textboxes.
> I assume someone has figured this out. We have 3 asp programmers and
> we are all stumped.
> "Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
> > For this purpose I used to create properties (in user control). This way
you
> > can also pass parameters from aspx file (html).
> > You can access Session to retrieve values. There're plenty of ways. In
case
> > you need some code, I'll try to post.
> > --
> > With the best wishes,
> > Shaul Feldman
> > "Ben" <Ben@.nospam.com> wrote in message
> > news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > > Hi
> > > > I am using a User Control which is referenced by an ASPX page.
> > > > How can I pass a string parameter to the user control, from the base
ASPX
> > > page.
> > > > Thanks
> > > > Ben
> >
Pass parameters to User Control
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
>
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
>
Sorry for the delay in replying:
I have heard that you can use this method to pass the parameter:
<%@.Register tagprefix="CodeLib" Tagname="usrMain" src="http://pics.10026.com/?src=usrMain.ascx" %>
<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/>
But the problem is that I cannot seem to extract the data on the ASCX page
Thanks Ben
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:e$%23BiHkJEHA.3944@.tk2msftngp13.phx.gbl...
> For this purpose I used to create properties (in user control). This way
you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In
case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
ASPX
>
Implement Properties inside of your UserControl
e.g.
Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property
Then just access the properties
"Lynne K." <ltgaer@.assurity.com> wrote in message
news:7a65e5b4.0405110605.559f0d2d@.posting.google.com...
> Help! I have an aspx that loads the ascx with parameters in a
> placeholder as textboxes. On my postback I can't get the values out
> of the textboxes. They are still on the screen so I'm sure they are
> there.
> I'm having a hard time. I've been told they should just be there.
> aspx
> ascx
> ascxwp
> The ascxwp is the user control that holds the textboxes.
> I assume someone has figured this out. We have 3 asp programmers and
> we are all stumped.
> "Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
you
case
ASPX
Pass parameters to User Control
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
--
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
Pass Session Variable Value to Crystal Report?
whenever they want to run a report. On this page, I have added an
additional text box for the user to enter in comments about the report
they are running.
I would like to be able to have the comments that the user has entered
to appear on the report that is generated. I thought that I might be
able to pass this text to the report by using a session variable but I
have had no luck. It doesn't matter if I use a session variable to
accomplish this.
Can someone tell me how I can the user's comments from the web form
appear on the report?
Thanks!I figured out a way to accomplish this. I created a session variable
named UComments and stored the text that the user typed in it. On my
Crystal Report I created a blank formula field named UserComments I
next added the following code to my web form:
Dim oRpt As CrystalDecisions.CrystalReports.Engine.ReportDocum ent
= New CrystalDecisions.CrystalReports.Engine.ReportDocum ent()
'*** TELLING THE PROGRAM WHER THE REPORT IS LOCATED
'*** AND WHAT THE REPORT'S NAME IS. ***
oRpt.Load(Session("ReportLocation") & "Grant.rpt")
'*** CODE TO WRITE USER'S COMMENTS TO THE REPORT. ***
oRpt.DataDefinition.FormulaFields.Item("UserComments").Text = "'"
+ Trim(Session("UComments")) + "'"
CrystalReportViewer1.ReportSource = oRpt
crjunk@.earthlink.net (crjunk) wrote in message news:<e45e90aa.0308061021.788041e6@.posting.google.com>...
> I've got an aspx page that allows the user to select different options
> whenever they want to run a report. On this page, I have added an
> additional text box for the user to enter in comments about the report
> they are running.
> I would like to be able to have the comments that the user has entered
> to appear on the report that is generated. I thought that I might be
> able to pass this text to the report by using a session variable but I
> have had no luck. It doesn't matter if I use a session variable to
> accomplish this.
> Can someone tell me how I can the user's comments from the web form
> appear on the report?
> Thanks!
Pass Session Variable from 1.1 to 2.0
v2.0 page, but haven't been able to do it. The reason is because I
need to embed the 1.1 page in my intranet portal tool so I can ask it
the user id that is currently logged in (using Plumtree, .. I mean
BEA). The portal only supports v1.1. I want to pass that session
variable to multiple pages externally that are running v2.0. Is this
possible? Please help.Since session is application-specific, even if they were both ASP.NET 2.0 yo
u
still couldn't do it, since they are each running in a separate appDomain.
You would likely need to come up with some external state mechanism using
remoting to store the "session" with a unique key to both apps someplace
"outside" of each app (database, etc.).
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"aperez" wrote:
> Hi, I need to pass a session variable from an ASP.NET v1.1 page to a
> v2.0 page, but haven't been able to do it. The reason is because I
> need to embed the 1.1 page in my intranet portal tool so I can ask it
> the user id that is currently logged in (using Plumtree, .. I mean
> BEA). The portal only supports v1.1. I want to pass that session
> variable to multiple pages externally that are running v2.0. Is this
> possible? Please help.
>
Pass Session Variable from 1.1 to 2.0
v2.0 page, but haven't been able to do it. The reason is because I
need to embed the 1.1 page in my intranet portal tool so I can ask it
the user id that is currently logged in (using Plumtree, .. I mean
BEA). The portal only supports v1.1. I want to pass that session
variable to multiple pages externally that are running v2.0. Is this
possible? Please help.Since session is application-specific, even if they were both ASP.NET 2.0 you
still couldn't do it, since they are each running in a separate appDomain.
You would likely need to come up with some external state mechanism using
remoting to store the "session" with a unique key to both apps someplace
"outside" of each app (database, etc.).
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"aperez" wrote:
Quote:
Originally Posted by
>
Hi, I need to pass a session variable from an ASP.NET v1.1 page to a
v2.0 page, but haven't been able to do it. The reason is because I
need to embed the 1.1 page in my intranet portal tool so I can ask it
the user id that is currently logged in (using Plumtree, .. I mean
BEA). The portal only supports v1.1. I want to pass that session
variable to multiple pages externally that are running v2.0. Is this
possible? Please help.
>
>
Pass SQL query to another page safely.
I have done this by treating the SQL (or the parameter parts of it) as a string, writing it to a database, then retrieving it from another page. Its not very elegant I know, but it works just fine if you have a specific unique key to identify your user.
regards
Mike
Two ways I can think of...If you are using response.redirect to move to the next page use session. Otherwise put the query into a page property, server.transfer to the new page, cast the httpcontext as the sending page and access the property. Or try this article on 4guys:
http://aspnet.4guysfromrolla.com/articles/020205-1.aspx
Yeah, I found somthing about the server.urlencode and server.urldecode that the article mentions. I'm not sure whether it will catch everything, but I'll see what happens.
Monday, March 26, 2012
pass table back to webpage
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 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 the Items on a post...??
(1) Use an HTML instead of a web form.
(2) Create a simple javascript function to alter the page behavior on the client...But there is a third method which is easy and good that is
(3) Pass the items on a post. Create a custion function to read the current items and send them via an HTTP post...
I neved attempted this and I donno how to do this...Can ne1 help me out how to do this...Ur help will be appreciatedAnd also I do not want to use Query Strings...I know we can redirect that using query strings...But is there any other way like the 3rd one without using query strings...
Here's a code sample that shows how to do what you want:
http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/intro/intro6.src
HI darellnorton,
Thanks for ur reply...But itz posting back to the same form which is not what I want...
One of the biggest differences between ASP and ASP.NET is that in ASP.NET, a Web Form must post back to itself rather than post to a different page.
Historically, developers posted to a different page by setting the form's action attribute. Posting to a separate page used to be a good idea because it made for a cleaner separation of code from HTML. Now, because ASP.NET handles events in the same Web Form in which they're raised, the form must post back to the same page. Even if you set the action attribute of the form to a different page, the Web server finds the runat="server" attribute setting and overrides your action value.
What you want is coming with ASP.NET v2.0, which will be available some time in 2005.
Hi DarrellNorton,
Thanks for ur reply..Yeah I have checked that it is gonna be released in aspv2.0...But how to do that if at all I want to implement it...Is there any way using the javascript to do that...Ur help will be appreciated
What you can do is use Server.Transfer(newPage.aspx), which will transfer control to the new page specified as well as the request object, so data in the request object will be available on the new page.
Try that and let me know how it works.
pass url parameter
I want to pass a URL parameter from a hyperlinked column in my datagrid to a data list on another page.
How do I construct the select statement for the datalist page please?
Cheers,
JbDo you mean you want the hyperlink URL to be something like:
/SomeDir/SomePage.aspx?ID=TheValueFromSomeDataSourceField
If so, use a HyperLinkColumn. Set its DataNavigateUrlField to the
DataSource field from where you want the databound data to come from.
Then, set the DataNavigateUrlFormatString to:
"/SomeDir/SomePage.aspx?ID={0}"
Essentially, put {0} in the string wherever you want the actual
database value to appear.
(copy and paste from a scott mitchell usenet posting.. ;-).. )
henkm.
Thanks for the reply but i meant on the other page.
select * from tbltable where class_ID = ??
cheers,
JB
The post var can be retrieved with(c#):
So, you sql is going to be something like:
string sqlSelect = "select * from tbltable where class_ID = " + Request.QueryString["ID"];
is this wat you wanted to see, or do your mean the full page code to retrieve the data and show it?
Careful with that, it is wide open to Sql Injection attacks: what happens if I call youpageurl.aspx?ID=1;delete * from tbltable ?
Well, you lose all your data...
Please consider the use of the SqlParameter object to securely build your Sql queries.
bleroy,
Thanks for pointing this out.
Do you know of any good articles or examples of using the sql parameter object for this case?
Thanks all,
JB
Sure,http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx#param should be a good start.
What if you want to pass 2 parameter in the DataNavigateURLFormatString like:
/SomeDir/SomePage.aspx?id={0}&id2={1}
Where will you put the second field?
Pass Username and Pwd to database query in WebMartix?
I have inserted a couple of label.texts to verify the variable make the second page.
How do I get the query to limit the return to only the records matching the UserName & Pwd combination?
Thanks,
ScottYou don't really want to pass the password around your site. And hopefully you're not allowing multiple duplicate usernames as long as the password is different.
If you're using asp.net authentication then it's somewhat safe to assume that the username is valid once they're logged in.
I.E. on your login page you set an authorization cookie.
On your details page you access their username via this cookie and use that as a parameter to your stored procedure/SQL Query.