Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Thursday, March 29, 2012

passing value to another page

hi,

i would like to redirect to customer.aspx from login aspx.

the code is

response.redirect(customer.aspx)

at the same time, i would like to pass the Login ID to customer.aspx. what code should i use for the customer.aspx as well as login.aspx in order to perform such function?

thanks

christeneThere are several options, of which just a few are:

1. Pass it in the URL
2. Store it in a session variable
3. Send it to the user's machine in a cookie.

Hope this helps,
Russ
well.........

my login is a button.
how i implement URL elements in a button control?

how do we use session variable?..i am not sure abt this....

hope u can explain futher...thanks a lot...

christene
What do you mean "My login is a button"? Can you tell me exactly what you have going on?
haha.....it means....

after the user type in the user name n password...they will click on a LOGIN BUTTON in order to log in....

well,i have done some testing using URL and it works...

response.redirect(customer.aspx?cusName = "& CustomerName &"")

on the customer.aspx,

Request.params("cusName")

right?

however, can u pls explain what is session variable?...i have heard about this but not sure what it is and how it works.....can u?

thanks...

christene
There is a good article on MSDN should you passing server control values between pages at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

Passing Values

Hi

I have two aspx pages in a frame and in the top page[top frame] i am
creating the controls[TextBox etc..] dynamically and putting in a place
holder. I have a hyperlink in this page[top frame] to populate the data in
the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
need to populate the bottom aspx page[bottom aspx page]based on the user
imputs. So i need to pass the values from the top aspx page [top frame] to
bottom aspx page[bottom frame]. how can i achieve this. Please give some
ideas...

Thanks in AdvanceSince these are just aspx pages, you should be able to the querystring, or
session variables to pass data between the 2 pages.
"Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have two aspx pages in a frame and in the top page[top frame] i am
> creating the controls[TextBox etc..] dynamically and putting in a place
> holder. I have a hyperlink in this page[top frame] to populate the data in
> the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
> need to populate the bottom aspx page[bottom aspx page]based on the user
> imputs. So i need to pass the values from the top aspx page [top frame] to
> bottom aspx page[bottom frame]. how can i achieve this. Please give some
> ideas...
>
> Thanks in Advance
I am using the hyperlink only to redirect the page. more if i am doing a
postback these text box values are not visible.I am getting an error 'Object
reference not set to an instance of an object'. So i am not able to set the
session also.

"Showjumper" <shojumper@.grkjashdjkf.com> wrote in message
news:uHw0LsD5DHA.1040@.TK2MSFTNGP10.phx.gbl...
> Since these are just aspx pages, you should be able to the querystring, or
> session variables to pass data between the 2 pages.
> "Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
> news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > I have two aspx pages in a frame and in the top page[top frame] i am
> > creating the controls[TextBox etc..] dynamically and putting in a place
> > holder. I have a hyperlink in this page[top frame] to populate the data
in
> > the bottom aspx page[bottom frame]. When the user clicks this hyperlink
i
> > need to populate the bottom aspx page[bottom aspx page]based on the
user
> > imputs. So i need to pass the values from the top aspx page [top frame]
to
> > bottom aspx page[bottom frame]. how can i achieve this. Please give some
> > ideas...
> > Thanks in Advance
> I am using the hyperlink only to redirect the page. more if i am doing a
> postback these text box values are not visible.I am getting an error
'Object
> reference not set to an instance of an object'. So i am not able to set
the
> session also.

The error probably means that you ar using a tag like <asp:Textbox
id="txtPipo"> in your aspx file but you do not declare a matching Textbox
object in your codebehind file like

Textbox txtPipo;

As for passing information, you can append all the data as name-value pairs
to the target url you pass to the redirect statement like

http:/someservername?name=pipo%20%address=woonwagen%20%o ccupation=clown

and then retrieve them through Request.QueryString as Showjumper already
suggested.

> "Showjumper" <shojumper@.grkjashdjkf.com> wrote in message
> news:uHw0LsD5DHA.1040@.TK2MSFTNGP10.phx.gbl...
> > Since these are just aspx pages, you should be able to the querystring,
or
> > session variables to pass data between the 2 pages.
> > "Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
> > news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> > > Hi
> > > > I have two aspx pages in a frame and in the top page[top frame] i am
> > > creating the controls[TextBox etc..] dynamically and putting in a
place
> > > holder. I have a hyperlink in this page[top frame] to populate the
data
> > > in the bottom aspx page[bottom frame]. When the user clicks this
> > > hyperlink i need to populate the bottom aspx page[bottom aspx page]
> > > based on the user imputs. So i need to pass the values from the top
> > > aspx page [top frame] to bottom aspx page[bottom frame]. how can
> > > i achieve this. Please give some ideas...
You can pass some values via client side code to a control (or hidden
control) in your other frame.
Here's some javascript code that might do the trick for you:
parent.FRAMENAME.document.form1.myhiddentextbox.va lue='test';

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

"Gibs" <dotnet_Gibs@.yahoo.com> wrote in message
news:uHkXScD5DHA.2412@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have two aspx pages in a frame and in the top page[top frame] i am
> creating the controls[TextBox etc..] dynamically and putting in a place
> holder. I have a hyperlink in this page[top frame] to populate the data in
> the bottom aspx page[bottom frame]. When the user clicks this hyperlink i
> need to populate the bottom aspx page[bottom aspx page]based on the user
> imputs. So i need to pass the values from the top aspx page [top frame] to
> bottom aspx page[bottom frame]. how can i achieve this. Please give some
> ideas...
>
> Thanks in Advance

passing values between aspx.vb pages

About javascript window.opener. How do I pass values from source.vb to object.vb if I use window.opener("target.aspx") in a javascript function? I want to use a separate .js file for this purpose.

My code looks something like this.

'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a onclick="newwindow()">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer

'scripts.js
function newwindow() {
myWin = opener("target.aspx");
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer

So, I would like to set variabletarget1 = variable1 and variabletarget2 = variable2 in the process. I am not using frames or iframes. MSDN says that window.opener works only in <frame> or <iframe> pages.

How to do this with javascript?

HenrixHi Henrix,
Somethig like this:


'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a runat="server">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer
...

a.Attributes.Add("onclick", "newwindow('"& variable1 & "'," & variable2 & ")"

'scripts.js
function newwindow(variable1, variable2) {
myWin = opener("target.aspx?variable1="+variable1+"&variable2="+variable2);
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer
...
variabletarget1 = Request.QueryString("variable1")
variabletarget2 = Int32.Parse(Request.QueryString("variable2"))

Passing values between pages with MasterPages

After a few hours of trial and error I have reached the following
conclusions, can you please tell me if I am right:
I have 2 aspx pages both with the same master page and I wish to pass
values from one to the other.
1. The postbackurl method doesn't seem to work with master pages. If I
take away the master pages it works.
2. The server.transfer method also doesn't work if I try to acess the
values via Request.Form or PreviousPage.FindControl. Again if I take
away the master pages it works.
3. My only option if I don't want to use the querystring to pass the
values (i.e. response.redirect) is to use a method which stores the
values in the server's RAM. e.g use Context.Items in conjunction with
Server.Transfer. This works with MasterPages but has the downfall of
the server's RAM now being used.
Please tell me if I am wrong or if there is no way of using cross page
posting or server.transfer for passing values from one aspx page with a
masterpage to another with the same masterpage without storing the
values in RAM?
Kind regards,
Steve."Steve" wrote:
> I have 2 aspx pages both with the same master page and I wish to pass
> values from one to the other.
Try using session variables, which should persist across page requests at a
user level:
1)
Session("SettingName") = strSettingValue
2)
strSettingValue = CStr(Session("SettingName"))

Passing values between pages with MasterPages

After a few hours of trial and error I have reached the following
conclusions, can you please tell me if I am right:

I have 2 aspx pages both with the same master page and I wish to pass
values from one to the other.

1. The postbackurl method doesn't seem to work with master pages. If I
take away the master pages it works.

2. The server.transfer method also doesn't work if I try to acess the
values via Request.Form or PreviousPage.FindControl. Again if I take
away the master pages it works.

3. My only option if I don't want to use the querystring to pass the
values (i.e. response.redirect) is to use a method which stores the
values in the server's RAM. e.g use Context.Items in conjunction with
Server.Transfer. This works with MasterPages but has the downfall of
the server's RAM now being used.

Please tell me if I am wrong or if there is no way of using cross page
posting or server.transfer for passing values from one aspx page with a
masterpage to another with the same masterpage without storing the
values in RAM?

Kind regards,

Steve."Steve" wrote:

Quote:

Originally Posted by

I have 2 aspx pages both with the same master page and I wish to pass
values from one to the other.


Try using session variables, which should persist across page requests at a
user level:

1)
Session("SettingName") = strSettingValue

2)
strSettingValue = CStr(Session("SettingName"))

Passing values between two pages

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

RegardsTry a Server.Transfer("WebForm2.aspx");
instead of Redirect.

Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi
>
In my source page I am using;
>
Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")
>
In my destination page in Page_Load event I am using;
>
lblMsg.Text = CType(Context.Items("Msg"), String)
>
But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?
>
Thanks
>
Regards
>
>


If you use Server.Transfer then on the next page you can reference the
PreviousPage object and use the FindControl method to gain reference to
whatever control you want on the previous page (the one that did the
transfer).

--
-Demetri

"sloan" wrote:

Quote:

Originally Posted by

Try a Server.Transfer("WebForm2.aspx");
instead of Redirect.
>
>
Note this technique does not work if you use Response.Redirect. A Redirect
results in another round trip to the client and a new HTTP request - thus a
new Context object without our ArrayList. To span requests, you'll need to
use the Session object or another state container. Also, there are other
techniques you can use to pass state between two forms when using
Server.Transfer, these other techniques can be found in the resources
section of the article.
http://www.odetocode.com/Articles/111.aspx
>
"John" <John@.nospam.infovis.co.ukwrote in message
news:eqgC28EpGHA.504@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hi

In my source page I am using;

Context.Items("Msg") = Msg
Response.Redirect("Destination_Page.aspx")

In my destination page in Page_Load event I am using;

lblMsg.Text = CType(Context.Items("Msg"), String)

But the value does not get to the destination page. Is there a more
reliable way to pass a string between pages?

Thanks

Regards


>
>
>

Passing values between Web Forms

Hi,

I have a web page which is split vertically into two by a frame, giving me LeftPage.aspx and RightPage.aspx.

Now then, I want to pass the contents of a few text boxes on LeftPage to some text boxes on RightPage.

How do I do it?

By the way, i'd like the passing to happen at the end of the Page_Load event on LeftPage.

Cheers,
DarrenHello, in the LeftFrame, you specify the link as follows:

Then you name the right frame = "rightFrame". Then, you have used querystrings to pass these values.

regards
Hi,

Thanks for the quick response, however your message does not show any code between your first line and then the line that starts "Then you name..." (i.e. it's blank).

Sorry i'm as thick as a whale omlette when it comes to APS.NET i've only just started... could you be more specific please (i.e. supply code??)

thanks in advance!

regards,
darren
By the way i've tried:

LEFT PAGE CODE:

Server.Transfer("RightPage.aspx")

... but this replaces the left page with the right page inside the left frame!!

regards,
darren


Link text

Replace the 'this' and 'that' with asp variables, or databinders, whatever it is you are using as the values.
Well, I beleive this is the same as my solution, but I didn't get any resposne ?

regards
Use the code that chrisbarr mentioned for the link.
Then in the rightpage.aspx code, use something like (in VB)

If Not Request.Params("a") Is Nothing Then
info = Request.Params("a")
End If

This should collect the information.
Does this help?

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.

passing values from main webform to include template pages

View a printable version of this message!I'm new to ASP.Net... I have a web page (myform.aspx) that is put together using 3 include files, header.cscx, left.cscx, & footer.cscx (each has their own .cscx.vb files). I want to assign some custom values on myform.aspx.vb, how can I get these custom values in my one of my includes files, ie. header.cscx.vb?
'**********This is myform.aspx*************
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="footer" src="http://pics.10026.com/?src=footer.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="left" src="http://pics.10026.com/?src=left.ascx"%>
<%@dotnet.itags.org. Register TagPrefix="UC" TagName="header" src="http://pics.10026.com/?src=header.ascx"%>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="myform.aspx.vb" Inherits="intranet.myform"%>
<UC:header id="header" runat="server" />
<UC:left id="left" runat="server" />
<TABLE><TR><td>My contents go here...</td></TR></TABLE>
<UC:footer id="footer" runat="server" />

'**********This is myform.aspx.vb*************
Public Class myform
Inherits System.Web.UI.Page
Protected WithEvents lblPageTitle As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPageTitle.Text = "Welcome to my home page!"
End Sub
End Class

'**********This is header.ascx*************
<%@dotnet.itags.org. Control Language="vb" AutoEventWireup="false" Codebehind="header.ascx.vb" Inherits="intranet.header" %>
'I don't have any HTML code here yet (all are in header.acsx.vb) b/c I'm still working on the sepration between HTML design and codebehind page.

'**********This is header.ascx.vb*************
Public Class header
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'How can I get the value of lblPageTitle here so I can display it in the HTML Title tag??
'I have other values that I want to pass to this page too, but for this example, I'm just trying to get the value of lblPageTitle from myform.aspx.vb
Response.Write("<HTML><HEAD>")
Response.Write("<title>lblPageTitle</title>")
Response.Write("</HEAD><BODY>")
...
End Sub
End Class1) Cookie
2) Session Variable
3) Query String
I think any of these will work for what you're describing. You'retrying to get som value to be accessible to your user controls from themain page.

Have you thought of using properties inside the usercontrols?
check this please:
An Extensive Examination of User Controls
The best reference to UserControls
Regards
Thank you so much, it's exactly what I need!
That is great, Im happy for you.
regards

Monday, March 26, 2012

Passing values to Stored Procedure

I have a C#.NET that simply passes 6 values to a Stored Procedure. But
I'm trying to get the (Default.aspx.cs page) to handle passing the
values to the sp. The goal is to pass the values and see if any
records are returned. I will later insert some conditional statements.
Here is my Default.aspx.cs
protected void btnNext_Click(object sender, EventArgs e)
{
Session["TotalTimeTo"] = TotalTimeTo.Text;
Session["TotalTimeFrom"] = TotalTimeFrom.Text;
Session["Locations"] = Locations.Text;
Session["Mh"] = Mh.Text;
Session["Dy"] = Dy.Text;
Session["Yr"] = Yr.Text;
Server.Transfer("page3.aspx");
/* Trying to pass to SP*/
string connectionStr =
@dotnet.itags.org." server=localhost;uid=user;pwd=pass;trust
ed_connection=true;database=Events
";
SqlConnection connectObj = new SqlConnection(connectionStr);
commandObj.Connection.Open();
commandObj.ExecuteNonQuery();
commandObj.Connection.Close();
}
Here is my stored procedure*********************
CREATE PROCEDURE CheckAvailableEvents
@dotnet.itags.org.Yr nvarchar(4)
,@dotnet.itags.org.Mh nvarchar(2)
,@dotnet.itags.org.Dy nvarchar(2)
,@dotnet.itags.org.Locations nvarchar(50)
,@dotnet.itags.org.TotalTimeTo nvarchar(12)
,@dotnet.itags.org.TotalTimeFrom nvarchar(12)
As
IF (SELECT Count(TotalTimeTo) from SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND
(Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo ) > 0
Select Top 1 Locations, TotalTimeTo, ContactPerson, Extension from
SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND (Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo
ELSE
Select Top 0 Locations from SpecialEvents
I get a little lost because a lot of the online tutorials are passing
the values to SqlAdapters!Try this. It uses "using" to implicitly clean up all your DB stuff when
disposed:
using (SqlCommand command = new SqlCommand(new SqlConnection(...)))
{
command.Parameters.Add("@.Param1", param1);
command.Parameters.Add("@.Param2", param2);
SqlParameter returnValue = new SqlParameter("@.Identity",
SqlDbType.BigInt);
returnValue.Direction = ParameterDirection.Output;
command.Parameters.Add(returnValue);
command.ExecuteNonQuery();
return (Int64) returnValue.Value;
}

Passing values to Stored Procedure

I have a C#.NET that simply passes 6 values to a Stored Procedure. But
I'm trying to get the (Default.aspx.cs page) to handle passing the
values to the sp. The goal is to pass the values and see if any
records are returned. I will later insert some conditional statements.

Here is my Default.aspx.cs

protected void btnNext_Click(object sender, EventArgs e)
{

Session["TotalTimeTo"] = TotalTimeTo.Text;
Session["TotalTimeFrom"] = TotalTimeFrom.Text;
Session["Locations"] = Locations.Text;

Session["Mh"] = Mh.Text;
Session["Dy"] = Dy.Text;
Session["Yr"] = Yr.Text;
Server.Transfer("page3.aspx");
/* Trying to pass to SP*/

string connectionStr =
@dotnet.itags.org."server=localhost;uid=user;pwd=pass;trusted_connect ion=true;database=Events";

SqlConnection connectObj = new SqlConnection(connectionStr);

commandObj.Connection.Open();
commandObj.ExecuteNonQuery();
commandObj.Connection.Close();
}

Here is my stored procedure*********************

CREATE PROCEDURE CheckAvailableEvents
@dotnet.itags.org.Yr nvarchar(4)
,@dotnet.itags.org.Mh nvarchar(2)
,@dotnet.itags.org.Dy nvarchar(2)
,@dotnet.itags.org.Locations nvarchar(50)
,@dotnet.itags.org.TotalTimeTo nvarchar(12)
,@dotnet.itags.org.TotalTimeFrom nvarchar(12)
As
IF (SELECT Count(TotalTimeTo) from SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND
(Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo ) 0

Select Top 1 Locations, TotalTimeTo, ContactPerson, Extension from
SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND (Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo

ELSE

Select Top 0 Locations from SpecialEvents

I get a little lost because a lot of the online tutorials are passing
the values to SqlAdapters!Try this. It uses "using" to implicitly clean up all your DB stuff when
disposed:
using (SqlCommand command = new SqlCommand(new SqlConnection(...)))
{
command.Parameters.Add("@.Param1", param1);
command.Parameters.Add("@.Param2", param2);
SqlParameter returnValue = new SqlParameter("@.Identity",
SqlDbType.BigInt);

returnValue.Direction = ParameterDirection.Output;
command.Parameters.Add(returnValue);
command.ExecuteNonQuery();

return (Int64) returnValue.Value;
}

passing values to showmodal dialog

I have parent.aspx web page from which I call a modal dialog (child.aspx via
showmodaldialog). I'd like to populate two text boxes, <asp:TextBox id=txt
_HN> on the child form with data from the caller.
for parent.aspx....
<script> block
function UpdH(title,horse)
{
var iParms=new Object();
iParms.Name=horse;
...}
for child.aspx...
<script> block
I've tried "document.getElementById('txt_HN').value=iParms.Horse;" within ch
ild.aspx form - but get error "document.getElementbyId(...) is null or not a
n object". How do I do this?David,
Try dialogArguments.window.document.getElementById....
using the following to open your window in java script:
var TestWindow = new Object();
TestWindow.caller = window.showModalDialog(URLstr, window, sFeatures);
replacing the parameters there with whatever you use as appropriate.
Raymond Lewallen
"DavidS" <DavidS@.discussions.microsoft.com> wrote in message
news:564EE97A-8C7D-4E35-B034-99BB78A95904@.microsoft.com...
> I have parent.aspx web page from which I call a modal dialog (child.aspx
via showmodaldialog). I'd like to populate two text boxes, <asp:TextBox
id=txt_HN> on the child form with data from the caller.
> for parent.aspx....
> <script> block
> function UpdH(title,horse)
> {
> var iParms=new Object();
> iParms.Name=horse;
> ...}
> for child.aspx...
> <script> block
> I've tried "document.getElementById('txt_HN').value=iParms.Horse;" within
child.aspx form - but get error "document.getElementbyId(...) is null or not
an object". How do I do this?

passing values to showmodal dialog

I have parent.aspx web page from which I call a modal dialog (child.aspx via showmodaldialog). I'd like to populate two text boxes, <asp:TextBox id=txt_HN> on the child form with data from the caller.
for parent.aspx....
<script> block
function UpdH(title,horse)
{
var iParms=new Object();
iParms.Name=horse;
...}
for child.aspx...
<script> block
I've tried "document.getElementById('txt_HN').value=iParms.Hor se;" within child.aspx form - but get error "document.getElementbyId(...) is null or not an object". How do I do this?David,

Try dialogArguments.window.document.getElementById... .

using the following to open your window in javascript:

var TestWindow = new Object();
TestWindow.caller = window.showModalDialog(URLstr, window, sFeatures);

replacing the parameters there with whatever you use as appropriate.

Raymond Lewallen

"DavidS" <DavidS@.discussions.microsoft.com> wrote in message
news:564EE97A-8C7D-4E35-B034-99BB78A95904@.microsoft.com...
> I have parent.aspx web page from which I call a modal dialog (child.aspx
via showmodaldialog). I'd like to populate two text boxes, <asp:TextBox
id=txt_HN> on the child form with data from the caller.
> for parent.aspx....
> <script> block
> function UpdH(title,horse)
> {
> var iParms=new Object();
> iParms.Name=horse;
> ...}
> for child.aspx...
> <script> block
> I've tried "document.getElementById('txt_HN').value=iParms.Hor se;" within
child.aspx form - but get error "document.getElementbyId(...) is null or not
an object". How do I do this?

passing values with request.redirect

I have 2 pages(aspx). I will paste the code below. I am trying pass the values through the form attributes. I dont get any error, but dont get the output too.

The code is:(first page login.aspx)
<%@dotnet.itags.org. Page Language="VB" %>
<%@dotnet.itags.org. import Namespace="System.Web" %>
<script runat="server"
sub submit(Source as object, e as eventargs)
Dim xml
xml=Server.CreateObject("Microsoft.XMLDOM")
xml.async=false
xml.load(Server.Mappath("users.xml"))

Dim user, password
user = xml.documentElement.childNodes(0).text
password = xml.documentElement.childNodes(1).text

if(user = UserName.text) then
response.redirect("welcome.aspx")
else
response.write("relogin please")
end if
end sub

sub reset(Source as object, e as eventargs)
UserName.text=""
pass.value=""
end sub

</script>
<html>
<head>
</head>
<body bgcolor="#ffffff">
<form action="Welcome.aspx" method="get" runat="server">
<p align="center">
Login Page
</p>
<p align="center">
Username:
<asp:TextBox id="UserName" runat="server"></asp:TextBox>
</p>
<p align="center">
Password: <input id="pass" type="password" name="pass" runat="server" />
</p>
<p align="center">
<input type="submit" value="Submit" runat="server" onserverclick="submit" /> <asp:Button id="Button2" onclick="reset" runat="server" Text="Reset"></asp:Button>
</p>
<p align="center">
Register
</p>
<p align="center">
</p>
<!-- Insert content here -->
</form>
</body>
</html
***************************************************************

Second Page: (welcome.aspx)
<%@dotnet.itags.org. Page Language="VB" %>
<script runat="server"
sub page_load
Response.Write("<h3><center>Welcome</h3></center>")
Response.Write(Request.QueryString("UserName"))
end sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
</form>
</body>
</html
It shows Welcome but does not show the username.On your submit sub where you redirect to the welcome page: Response.Redirect("welcome.aspx"), yea, there's nothing in the QueryString. QueryString values are appended after the url. A possible fix would be to re-write that line to say: Response.Redirect("welcome.aspx?UserName="&user)
Try adding the a querystring to your Response.Redirect call on the first page. For example:

Response.Redirect("welcome.aspx?UserName=" & user)
You know that .NET has already done what you're trying to do don't you?

Search the forum for Login Page and/or User.Identity.Name and you'll find some examples.

Saturday, March 24, 2012

Passing variables

I need help passing some variables from an aspx page to a pop up window. I tried using querystring but somehow it's not passing it correctly. Below is what I have:

Mainpage code behind. This is pulling the user's name that the user enter at login. The session works for this.

Dim strAuthUsr as String

strAuthUsr = Session("AuthUsr")

This is where I put the tag:

Onclick = "windowOpen('http://intranet/Quotes/NewQuote.aspx?user=<%#strAuthUsr%>', 'NewQuote');"

New window that is being open from the javascript above that uses the querystring:

Dim strAuthUser As String

strAuthUsr = Request.QueryString("user")
txbUser.Text = strAuthUsr

The only thing output I got for that textbox is <%. I'm not sure if my syntax is right, but please advise.Why not:

Onclick = "windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUsr & "', 'NewQuote');"

You are constructing this in the code-behind, right?

Brian
<Elmer Fudd Voice>
Be veddy veddy karefull when using popups... huhuhuhuhuh...
</Elmer Fudd Voice
Most browsers block them by default these days, this can cause you ALOT of pain.

Just a thought.
Brian,

I tried using the syntax as you suggested, but I get an error. Says that the server tag is not well formed.

There's also squiggle line under the strAuthUsr string. Says that it could not find any attribute 'strAuthUsr' of element 'input'

Yes, I am constructing this in the code-behind.

The Quote.aspx.vb is coded as followed:


Dim strAuthUsr as String

strAuthUsr = Session("AuthUsr")

From the Quote.aspx is coded as followed:


Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"

This is for the pop window:


Dim strAuthUsr As String

strAuthUsr = Request.QueryString("user")

txbUser.Text = strAuthUsr

I want to pass the user name from session that the user entered to get into the main page to be displayed on the txbUser.Text textbox.

I can pass the variable from page to page, but somehow this pop up window is not letting me. I don't know if the javascript has anything to do with it, but I doubt it.

<script language="javascript">
function windowOpen(sURL,sWinName){
var params = 'height=410,width=450,directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=no,resizeable=no';
window.open(sURL,sWinName,params);
}
</script

Please advise.
Probably I should ask this. The string "strAuthUsr = Session("AuthUsr")" does show the username when I go to debug.

The

Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"
, I'm assuming should pull that variable. Is there a way to see if the username is being pull? I did try a
Response.Write("user")
, but all i'm getting is sometime <% or sometime nothing.

From my understanind the strAuthUsr string should be pass as variable when using <%#strAuthUsr%>, but I'm not sure why it's not doing that in this case.

Any suggestions on how I can do a generic pass, for example something static just to make sure that it does pass from one page to the next?
I beleive if you use my free controlPopUpWindow 1.1, you would have any problem. Since you can open a pop up window from inside server-side.

regards
For this to work, this can't be in aspx:

Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"

You need to add it in .aspx.vb file. You may be able to do this through the Attributes.Add, which would add it so that it would render directly as is on the client.

Brian
In addition, if the user name is stored in the Session, it may be better to keep it there, redirect to the page, and check the session for this value, instead of going server/client, and then most likely server again. Or are you posting it outside your web site.

Brian
Brian thanks for responding. I'm not really clear on your post. For the code that I posted


Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"

How could this be in aspx.vb file when this is for the aspx server tag? The entire code for this is like this.


<input id="btnNewQuote" type="button" Onclick="windowOpen('http://intranet/Quotes/NewQuote.aspx?user=" & strAuthUser & "', 'NewQuote');"
value = "New Quote" runat="server" >

As for the session, it does not work because this is passing it from my page to a pop up window. I tried to call it from my previous page for the session variable and hopefully be able to pass it to the pop window, but it's not grabbing the value.

Any ideas?
I would recommend you check my control. It has what you need.

regards
haidar bilal, I had downloaded your control and will use it. If I have any questions, I will post you some.

Thanks.
Haidar Bilal,

Can your control open multiple pop up windows? I want to open a pop for users to fill in a small form, and from that pop up they can click on a button to open another pop where it has list of customers that they can click on to have those information filled in to the first pop up window.

So far, each pop up that i will replaces the current pop up window. WOndering if it can be done and how.

Thanks.
I hate to be redundent but you guys are going to need to be VERY carefull with popups. Almost all browsers have default popup blockers in them. Including IE6 with SP2 and Firefox 1.0.

Some popup blockers are even starting to block user execute popups.

You'll save yourself time and frustration if you avoid them.

Hope this helps,
Thanks for the warning adurstew, but this is for an intranet portal application. We had used it in the past with no problem so I don't see it as a concern.
Are your users running Windows XP? If so when your company rolls out SP2 a popup blocker is installed and running by default.

Passing Variables Between Pages

I have a problem passing information between pages.

I have a page (SendingPage.aspx) that uses the DataReader to gather data from an Access Database and populates a label with the created variable.
<asp:Label id="lbl1" runat="server" text="<%# streetNuml %
This works just fine.

I then want to pass the data in 'lbl1" to another page (ReceivingPage.aspx) on a button click using

httpContext.Current.Items.Add( "StreetNumu", lbl1.text)
Server.Transfer("ReceivingPage.aspx")

and populate a text box

textbox1.text = HttpContext.Current.Items( "StreetNum" )

but it does work. Blank textbox.

Any help or a solution would be greatly appreciated. Thanks DylanTry using the Server.Transfer method overload that preserves the form variables.

Server.Transfer("blah.aspx", True)
I don't believe this will work even with the preserveForm parameter set to true.

Server.Transfer only preserves the Forms and QueryString collection which is read-only on the server-side. So it is not possible to add something to the collection so that the destination page will be able to reference it.

In this case it might be better to use a simple Response.Redirect with a querystring in order to pass the value.

hope this helps,
sivilian
Thank You for the replies. I've tried both techniques mentioned.

I think the main question, and I've realized this recently, is how to convert a
dynamic variable <%# ...... %> to a static variable that is not associated with the value provided by the database. I think this is possible, but how? Any thoughts.... Thanks again.

Cheers

Dylan

Passing variables between sub procedures

I am currently coding in VB.Net.

I have used the folloiwng code to retrieve a variable value from a sending aspx page in the recieveing aspx page within the Sub Page_Load procedure:

Dim UsernameRecd as String
UsernameRecd = Context.Items("Username")

Which works fine.

However within the recieving aspx page l have another sub procedure based upon a click event on a button web control which also needs the above variable value but l cannot seem to retian the above value once the user clicks the button.

Is there a way to retrieve the variable value agian or do l have to store (and retrieve) the value once the page loads?

Help.

Parm.Store (and retrieve) the value

MajorCats

Passing Variables between script files and aspx files

Hello all,

I have a aspx.vb files which some global declarations within,


<FONT color=#0000ff size=2>Partial</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Class</FONT><FONT size=2> _Default
</FONT><FONT color=#0000ff size=2>Inherits</FONT><FONT size=2> System.Web.UI.Page</FONT><FONT size=2> <P></FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> TheGood </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0
</FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> TheBad </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0
</FONT><FONT color=#0000ff size=2>Dim</FONT><FONT size=2> TheWarning </FONT><FONT color=#0000ff size=2>As</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Integer</FONT><FONT size=2> = 0

...

How can I access these from a label within the .aspx file?


<FONT color=#0000ff size=2><</FONT><FONT color=#a31515 size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 size=2>Label</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>ID</FONT><FONT color=#0000ff size=2>="lbStatus"</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>runat</FONT><FONT color=#0000ff size=2>="server"</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>Text</FONT><FONT color=#0000ff size=2>="TheWarning"</FONT><FONT size=2> </FONT><FONT color=#ff0000 size=2>Width</FONT><FONT color=#0000ff size=2>="300px"></</FONT><FONT color=#a31515 size=2>asp</FONT><FONT color=#0000ff size=2>:</FONT><FONT color=#a31515 size=2>Label</FONT><FONT color=#0000ff size=2>>

Dead6re:

Hello all,

I have a aspx.vb files which some global declarations within,


PartialClass _DefaultInherits System.Web.UI.Page

Dim TheGoodAsInteger = 0
Dim TheBadAsInteger = 0
Dim TheWarningAsInteger = 0...

How can I access these from a label within the .aspx file?

<asp:LabelID="lbStatus"runat="server"Text="TheWarning"Width="300px"></asp:Label>

lbStatus.Text = TheWarning.ToString()


1PartialClass _DefaultInherits System.Web.UI.Page

2Dim TheGoodAs Integer = 0Dim TheBadAs Integer = 0Dim TheWarningAs Integer = 0

1<asp:Label ID="lbStatus" runat="server" Text="TheWarning" Width="300px"></asp:Label>

i am not getting in which scenario it would be required...

can you tell me what is your exact requirement ?

passing variables between usercontrols

Is there an easy way to pass variables between two different usercontrols within an aspx page?In fact, i've found a way to get the initial value of a variable within a user control modifying some code I found off a tutorial on the net, but the problem is that it can only retrieve the initial value, no other value. Is there any way to modify this? Here is the code i've used

Control _myControl = Page.FindControl("MyControl1");
Type _myControlType = _myControl.GetType();
PropertyInfo _myUC_EndDate = _myControlType.GetProperty("EndDate");
EndDate.Text = _myUC_StartDate.GetValue(_myControl, null).ToString();
You can create public properties on the user control, then access the property via UserControl:Property...

/*
example:

myControl.ascx

*/

private string name; // the name field
public string Name{
get{
return name;
}
set{
name = value;
}
}
i've actually tried that method, but that seems to return the initial value of the variable if there is any.
Are you getting the value at Page_Load?

If you are setting the value on a click method for instance, it will be one step behind. Click it twice in a row and see if it has the results you were expecting after the second click.

:-)
yes, i am setting the value on a click method. But i do not really want to have to click the button twice in a row to be able to retrieve the new values. Is there no way to change this?
LOL,

no no, just checking if that was the case. I have the same problems sometimes --

ok, so what you need to do on the in the click event is make sure you rebind the data to the control.
thanks for that, I may be tempted to change how my code currently works at the moment (coz it's currently working but not exactly to my preferred choice), and implement this later. I had thought before that I would have needed to pass the variables across as events.