Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Thursday, March 29, 2012

passing values between pages (one is previouspage) with asp.net 1.x

i have a page opens a popup in that popup i get some property values for control in the previous page

i need to pass the values to the control vwhen i clik a button

what is the best choise

when i need session i can'nt refresh the previous page correctly so it fails for me (browser asks me a msgbox)

when i want to pass with query string my value is a html tag it allso fails because of security

thanks for helps

i realy need help talk to me guys

Can you clarify the question a bit.

You have a window you pop up that gathers some data that you want to write back to the previous page that the window popped up from?

If so you can use javascript to do it:


function SelectItem(item, invalue)
{
if (window.opener)
if (window.opener.closed == false)
if (window.opener.document && window.opener.document.forms[0] &&
window.opener.document.forms[0].elements[item])
{
window.opener.document.forms[0].elements[item].value = invalue;
}
window.close();
}

Passing values from a child window

hi all,
I have a parent window default.aspx which has a textbox(txtBox1) with
multiline property and a button.when the button is clicked a child
window pops up child.aspx.
I have four textboxes in child.aspx and a submit button.What I want to
happen is when I click the submit button all the values must be
displayed in the multiline textbox in a table format with header and
the values below or any formatted display with headers.
I am using,
window.opener.documents.forms[0].txtBox1.value method to pass the
values.
can anybody help me to fix the values from the child window to the
parent window in a formatted display.I have been trying this for a day.
thanksHello ssrivani@.gmail.com,
From what I understood, after opening the child window and filling in the ch
ild form, you want to be able to:
1- Format the form field values in an html table.
2- copy the resulting html to the opening window and have it inserted into t
he multi line text field.
Try the attached files and see if it works for you.

> hi all,
>
> I have a parent window default.aspx which has a textbox(txtBox1) with
> multiline property and a button.when the button is clicked a child
> window pops up child.aspx.
> I have four textboxes in child.aspx and a submit button.What I want to
> happen is when I click the submit button all the values must be
> displayed in the multiline textbox in a table format with header and
> the values below or any formatted display with headers.
> I am using,
> window.opener.documents.forms[0].txtBox1.value method to pass the
> values.
> can anybody help me to fix the values from the child window to the
> parent window in a formatted display.I have been trying this for a
> day.
>
> thanks
>

passing values from form to form

I was wondering if it is possible to pass values from one aspx page to another aspx page using properties?

I want to create a property on the 2nd aspx page lets say Name(), and pass in the values from the first aspx page. I know how to pass values like this to a user control, but is it possible to pass it to another aspx page?> I was wondering if it is possible to pass values from one aspx page to another aspx page using properties?

You can sort of do this, but not as directly as you're suggesting.

In your firstpage.aspx:

Public Sub Button_Click( sender As Object, e As EventArgs )
Session( "Name" ) = "Value from textbox, or wherever"
Response.Redirect( "secondpage.aspx" )
End Sub

Then, in your secondpage.aspx:

Private _name As String
Public Property Name As String
Get
Return _name
End Get
Set
_name = Value
End Set
End Property

Public Sub Page_Init( sender As Object, e As EventArgs )
Name = Session( "Name" )
End Sub

If that doesn't help, perhaps you can explain more fully what you're trying to do.
That's what I'm trying to do. I knew that I can use session variables, just wondering if there's any other way to accomplish this.
You can store information into the QueryString as well.
Well, you can't directly access the second Page's properties from the first page, no.

After all, the second Page is not instantiated until the first is destroyed. So there can be no direct messaging between them.

It is for this reason that session variables exist. So, for "form to form" communication, session variables are ideal.

You can also create a single form thatacts like more than one form. If you're trying to keep information "alive" during a certain series of tasks, this might be a better way to go.

Saturday, March 24, 2012

passing variables

When I try that it tells me that property is read - only!
any ideas.
thanks
Phil.
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%234djVFU1DHA.4032@dotnet.itags.org.tk2msftngp13.phx.gbl...
> I set mine into the
> Page.User.Identity.Name
> Then I always have the userID accessable across the app/site
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
> "Phil Barber" <barber@dotnet.itags.org.galtney.com> wrote in message
> news:e3TFmBU1DHA.3196@dotnet.itags.org.TK2MSFTNGP11.phx.gbl...
> > I have a login page (page1) on successful login I retrieve an employeeID
> > from a SQL Database.
> > then move to a 2nd page. What is the best way to get the EmployeeID from
> > Page 1 to Page2
> > I have had problems with global variables in the past concerning
sessions.
> > thanks.
> > Phil BarberIt's when I use Forms Auth, like this
FormsAuthentication.SetAuthCookie(userID,false);

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com

"Phil Barber" <barber@.galtney.com> wrote in message
news:%23Go$s9U1DHA.4032@.tk2msftngp13.phx.gbl...
> When I try that it tells me that property is read - only!
> any ideas.
> thanks
> Phil.
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:%234djVFU1DHA.4032@.tk2msftngp13.phx.gbl...
> > I set mine into the
> > Page.User.Identity.Name
> > Then I always have the userID accessable across the app/site
> > --
> > Curt Christianson
> > Owner/Lead Developer, DF-Software
> > www.Darkfalz.com
> > "Phil Barber" <barber@.galtney.com> wrote in message
> > news:e3TFmBU1DHA.3196@.TK2MSFTNGP11.phx.gbl...
> > > I have a login page (page1) on successful login I retrieve an
employeeID
> > > from a SQL Database.
> > > then move to a 2nd page. What is the best way to get the EmployeeID
from
> > > Page 1 to Page2
> > > > I have had problems with global variables in the past concerning
> sessions.
> > > > thanks.
> > > > Phil Barber
> >

passing variables between web page events & httpmodules events

Use the item property on the httpcontext object. It's a dictionary object
which stores key/pair values but it is available every the httpcontext
object is available.

Regards

--

----
Got TidBits?
Get it here: www.networkip.net/tidbits
"shiv" <kadalli@dotnet.itags.org.hotmail.com> wrote in message
news:082a01c3b295$6d2db890$a501280a@dotnet.itags.org.phx.gbl...
> hi all,
> I need to access some variables which are generated in
> preRequestHandler Event in httpModule. I need these
> variables in Page ButtonControl Click event. Is that
> possible? I don't want to use session variables here. has
> anybody got some inputs here.
> Thanks in advance,
> regards
> shivThanks Alvin,
I too found out the same. You reaffirmed my findings!.
Thanks a millon!

regards
shiv
>--Original Message--
>Use the item property on the httpcontext object. It's a
dictionary object
>which stores key/pair values but it is available every
the httpcontext
>object is available.
>Regards
>--
>
>----
>Got TidBits?
>Get it here: www.networkip.net/tidbits
>"shiv" <kadalli@.hotmail.com> wrote in message
>news:082a01c3b295$6d2db890$a501280a@.phx.gbl...
>> hi all,
>>
>> I need to access some variables which are generated in
>> preRequestHandler Event in httpModule. I need these
>> variables in Page ButtonControl Click event. Is that
>> possible? I don't want to use session variables here.
has
>> anybody got some inputs here.
>> Thanks in advance,
>> regards
>> shiv
>>
>
>.

Passing variables from ASPX page to ASCX control

I'm sure this has come up before but I could not find any post on it.

How can I read a variable or property that has been set on a ASPX page from
inside a ASCX control.

ASPX code:

public partial class MyClass: System.Web.UI.Page
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
}
}
....etc...

ASCX code:

public partial class Controls_MyControl: System.Web.UI.UserControl,
IPostBackDataHandler
{
protected void Page_Load(object sender, EventArgs e)
{
Page callingPage = (Page) this.Page;
//How to read the "CompanyID" property from the calling page??
}

Thanks,
FernandoChange this line of code:

Page callingPage = (Page) this.Page;

to:

MyClass callingPage = (MyClass) this.Page;

Fernando Chilvarguer wrote:

Quote:

Originally Posted by

I'm sure this has come up before but I could not find any post on it.
>
How can I read a variable or property that has been set on a ASPX page from
inside a ASCX control.
>
ASPX code:
>
public partial class MyClass: System.Web.UI.Page
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
}
}
...etc...
>
ASCX code:
>
public partial class Controls_MyControl: System.Web.UI.UserControl,
IPostBackDataHandler
{
protected void Page_Load(object sender, EventArgs e)
{
Page callingPage = (Page) this.Page;
//How to read the "CompanyID" property from the calling page??
}
>
Thanks,
Fernando


Thanks KJ.

But when I change to MyClass my code does not compile.
How to I add a reference to that class in my Control?

Thanks,
Fernando
"KJ" <n_o_s_p_a__m@.mail.comwrote in message
news:1157043962.662681.143570@.m73g2000cwd.googlegr oups.com...

Quote:

Originally Posted by

Change this line of code:
>
Page callingPage = (Page) this.Page;
>
to:
>
MyClass callingPage = (MyClass) this.Page;
>
Fernando Chilvarguer wrote:

Quote:

Originally Posted by

>I'm sure this has come up before but I could not find any post on it.
>>
>How can I read a variable or property that has been set on a ASPX page
>from
>inside a ASCX control.
>>
>ASPX code:
>>
>public partial class MyClass: System.Web.UI.Page
>{
> protected string _companyID;
> public string CompanyID
> {
> get
> {
> return _companyID;
> }
> set
> {
> _companyID = value;
> }
> }
>...etc...
>>
>ASCX code:
>>
>public partial class Controls_MyControl: System.Web.UI.UserControl,
>IPostBackDataHandler
>{
> protected void Page_Load(object sender, EventArgs e)
> {
> Page callingPage = (Page) this.Page;
> //How to read the "CompanyID" property from the calling page??
> }
>>
>Thanks,
>Fernando


>


I should have recognized that you are using .net 2.0 (this would
compile in 1.x).

In this case, I do not know of a means for referencing the parent page
because doing so (using the @.Reference directive, for example) would
create a circular reference.

I think a better design approach would be for the parent page to *tell*
the user control what its CustomerID is.

That is to say, create a method or property, such as SetCustomerId() or
CustomerID, on the control, rather than having the control attempt to
pull the value from the hosting page.

This may seem like double work, but, it is actually better design
because you can now put your control on *any* page without requiring
the hosting page to declare certain properties. The control is supposed
to be a self-contained entity (black box).

For example:

public partial class MyClass: System.Web.UI.Page
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
myControl.CompanyID = value; //keeps the control and page in sync
}
}

ASCX code:

public partial class Controls_MyControl: System.Web.UI.UserControl,
IPostBackDataHandler
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
}
}
}

Fernando Chilvarguer wrote:

Quote:

Originally Posted by

Thanks KJ.
>
But when I change to MyClass my code does not compile.
How to I add a reference to that class in my Control?
>
Thanks,
Fernando
"KJ" <n_o_s_p_a__m@.mail.comwrote in message
news:1157043962.662681.143570@.m73g2000cwd.googlegr oups.com...

Quote:

Originally Posted by

Change this line of code:

Page callingPage = (Page) this.Page;

to:

MyClass callingPage = (MyClass) this.Page;

Fernando Chilvarguer wrote:

Quote:

Originally Posted by

I'm sure this has come up before but I could not find any post on it.
>
How can I read a variable or property that has been set on a ASPX page
from
inside a ASCX control.
>
ASPX code:
>
public partial class MyClass: System.Web.UI.Page
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
}
}
...etc...
>
ASCX code:
>
public partial class Controls_MyControl: System.Web.UI.UserControl,
IPostBackDataHandler
{
protected void Page_Load(object sender, EventArgs e)
{
Page callingPage = (Page) this.Page;
//How to read the "CompanyID" property from the calling page??
}
>
Thanks,
Fernando



define an interface in app_code that returns companyid. the have you pages
implement the interface (could inherit from a base page that implments the
interface. cast the page to the interface, and call method.

-- bruce (sqlwork.com)

"Fernando Chilvarguer" <fernando@.no-spam-impex.comwrote in message
news:uQ%23o97RzGHA.2036@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

I'm sure this has come up before but I could not find any post on it.
>
How can I read a variable or property that has been set on a ASPX page
from inside a ASCX control.
>
ASPX code:
>
public partial class MyClass: System.Web.UI.Page
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
}
}
...etc...
>
ASCX code:
>
public partial class Controls_MyControl: System.Web.UI.UserControl,
IPostBackDataHandler
{
protected void Page_Load(object sender, EventArgs e)
{
Page callingPage = (Page) this.Page;
//How to read the "CompanyID" property from the calling page??
}
>
Thanks,
Fernando
>


Thanks again KJ.

I used the suggested aproach (black-box) and it's all working great!
I set all the control properties from the aspx page. I also implemented all
the error-handling in case the control gets dropped into a page that does
not set up its properties.

THANKS!

"KJ" <n_o_s_p_a__m@.mail.comwrote in message
news:1157061762.574176.201880@.h48g2000cwc.googlegr oups.com...

Quote:

Originally Posted by

>I should have recognized that you are using .net 2.0 (this would
compile in 1.x).
>
In this case, I do not know of a means for referencing the parent page
because doing so (using the @.Reference directive, for example) would
create a circular reference.
>
I think a better design approach would be for the parent page to *tell*
the user control what its CustomerID is.
>
That is to say, create a method or property, such as SetCustomerId() or
CustomerID, on the control, rather than having the control attempt to
pull the value from the hosting page.
>
This may seem like double work, but, it is actually better design
because you can now put your control on *any* page without requiring
the hosting page to declare certain properties. The control is supposed
to be a self-contained entity (black box).
>
For example:
>
public partial class MyClass: System.Web.UI.Page
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
myControl.CompanyID = value; //keeps the control and page in sync
}
}
>
>
ASCX code:
>
public partial class Controls_MyControl: System.Web.UI.UserControl,
IPostBackDataHandler
{
protected string _companyID;
public string CompanyID
{
get
{
return _companyID;
}
set
{
_companyID = value;
}
}
}
>
Fernando Chilvarguer wrote:

Quote:

Originally Posted by

>Thanks KJ.
>>
>But when I change to MyClass my code does not compile.
>How to I add a reference to that class in my Control?
>>
>Thanks,
>Fernando
>"KJ" <n_o_s_p_a__m@.mail.comwrote in message
>news:1157043962.662681.143570@.m73g2000cwd.googlegr oups.com...

Quote:

Originally Posted by

Change this line of code:
>
Page callingPage = (Page) this.Page;
>
to:
>
MyClass callingPage = (MyClass) this.Page;
>
Fernando Chilvarguer wrote:
>I'm sure this has come up before but I could not find any post on it.
>>
>How can I read a variable or property that has been set on a ASPX page
>from
>inside a ASCX control.
>>
>ASPX code:
>>
>public partial class MyClass: System.Web.UI.Page
>{
> protected string _companyID;
> public string CompanyID
> {
> get
> {
> return _companyID;
> }
> set
> {
> _companyID = value;
> }
> }
>...etc...
>>
>ASCX code:
>>
>public partial class Controls_MyControl: System.Web.UI.UserControl,
>IPostBackDataHandler
>{
> protected void Page_Load(object sender, EventArgs e)
> {
> Page callingPage = (Page) this.Page;
> //How to read the "CompanyID" property from the calling page??
> }
>>
>Thanks,
>Fernando
>


>