Thursday, March 29, 2012
passing values
pass to the server when a form is submited?For each form field in the form, a value will be passed.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"rpp" <rpsur@.yahoo.com> wrote in message
news:8fccfb65.0312110716.52e2e776@.posting.google.c om...
> is there a way to choose which values to
> pass to the server when a form is submited?
passing values from a web page into windows form application
How can I pass session/application values from a web page (ASP or
ASP.NET) that is on a host company, into my cliente application?
So I can hide menus based on access permisions once the user makes the
log in in the web page by the application.
I'm using VB.NET with Web Control COM
Thank you
Bruno Alexandre
(Sintra, PORTUGAL)Hi Bruno,
You could post the values to a page from your site containing a vb6
component. The vb6 component would run in-process and with a reference to
the 'Microsoft Active Server Pages Object Library' you could then query the
session and application variables ASPTypeLibrary.Session and
ASPTypeLibrary.Application.
I have a sample program which isfreely available from a demonstration I did
on this a while back available at
http://www.crainiate.net/downloads/vb6wsdemo.zip
This component would then need to notify your application across process's,
there are a number of ways of doing this.
Your client would however need to run IIS, so this solution is limited to
windows2000 or windowsXP.
Kind regards,
James
--
Create interactive flowcharts, diagrams and UML models with ERM3 at
http://www.crainiate.net
"Bruno Alexandre" <bruno.alexandre@.filtrarte.com> wrote in message
news:uWoY6OsoDHA.2188@.TK2MSFTNGP11.phx.gbl...
> Hi guys,
> How can I pass session/application values from a web page (ASP or
> ASP.NET) that is on a host company, into my cliente application?
> So I can hide menus based on access permisions once the user makes the
> log in in the web page by the application.
> I'm using VB.NET with Web Control COM
>
> Thank you
> Bruno Alexandre
> (Sintra, PORTUGAL)
passing values from form to form
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 PropertyPublic 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.
Monday, March 26, 2012
passing values from one web form to another web form
dropdown list. It has one button called Submit.
when I click that button it should pass all the data from text boxes
and dropdown lists to another web form named processform.aspx.
So, my question is how can I pass the data from one web form to
another web form by clicking abutton.
ThanksIf you are using Server.Transfer method or cross-page posting, you can use
PreviousPage property to access the originating page.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
<bbawa1@.yahoo.com> wrote in message
news:1181585117.479238.102680@.n15g2000prd.googlegroups.com...
> I have a web form welcome.asp and it has three textboxes and two
> dropdown list. It has one button called Submit.
> when I click that button it should pass all the data from text boxes
> and dropdown lists to another web form named processform.aspx.
> So, my question is how can I pass the data from one web form to
> another web form by clicking abutton.
> Thanks
>
If this is a form post, you also have access to either the form or the query
string.
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@.mMvVpPsS.org> wrote in
message news:OZWVDQFrHHA.3456@.TK2MSFTNGP02.phx.gbl...
> If you are using Server.Transfer method or cross-page posting, you can use
> PreviousPage property to access the originating page.
> --
> Eliyahu Goldin,
> Software Developer & Consultant
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
>
> <bbawa1@.yahoo.com> wrote in message
> news:1181585117.479238.102680@.n15g2000prd.googlegroups.com...
>
On Jun 11, 12:15 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> If you are using Server.Transfer method or cross-page posting, you can use
> PreviousPage property to access the originating page.
> --
> Eliyahu Goldin,
> Software Developer & Consultant
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin
> <bba...@.yahoo.com> wrote in message
> news:1181585117.479238.102680@.n15g2000prd.googlegroups.com...
>
>
>
>
>
> - Show quoted text -
When I use Server.Transfer["ProcessForm.aspx"]; my btn_click event
it gives me following error message
only assignments, call, increment, decrement, and new object
expressions can be used as a statement
cannot apply indexing with [] to an expression of type 'method group'
Ysgrifennodd bbawa1@.yahoo.com:
> I have a web form welcome.asp and it has three textboxes and two
> dropdown list. It has one button called Submit.
> when I click that button it should pass all the data from text boxes
> and dropdown lists to another web form named processform.aspx.
> So, my question is how can I pass the data from one web form to
> another web form by clicking abutton.
> Thanks
>
I take the view that computer programs are usually modeling some real
world object or objects. I therefore construct server side object(s)
that store information entered via Pages in its/their state variables
(fields/properties/attributes).
On submit, I do any validation of the data that is required, store the
data in the object(s) and then store a reference to the object(s) in the
Session.
It is then a simple matter to retrieve that object and its data from the
Session in any subsequent form.
HTH
Peter
ASP.NET provides a plethora of ways to pass data between pages.
I've detailed virtually every technique here:
http://SteveOrr.net/articles/PassData.aspx
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
<bbawa1@.yahoo.com> wrote in message
news:1181585117.479238.102680@.n15g2000prd.googlegroups.com...
>I have a web form welcome.asp and it has three textboxes and two
> dropdown list. It has one button called Submit.
> when I click that button it should pass all the data from text boxes
> and dropdown lists to another web form named processform.aspx.
> So, my question is how can I pass the data from one web form to
> another web form by clicking abutton.
> Thanks
>
passing values from one web form to another web form
dropdown list. It has one button called Submit.
when I click that button it should pass all the data from text boxes
and dropdown lists to another web form named processform.aspx.
So, my question is how can I pass the data from one web form to
another web form by clicking abutton.
ThanksIf you are using Server.Transfer method or cross-page posting, you can use
PreviousPage property to access the originating page.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
<bbawa1@.yahoo.comwrote in message
news:1181585117.479238.102680@.n15g2000prd.googlegr oups.com...
Quote:
Originally Posted by
I have a web form welcome.asp and it has three textboxes and two
dropdown list. It has one button called Submit.
>
when I click that button it should pass all the data from text boxes
and dropdown lists to another web form named processform.aspx.
>
So, my question is how can I pass the data from one web form to
another web form by clicking abutton.
>
Thanks
>
If this is a form post, you also have access to either the form or the query
string.
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@.mMvVpPsS.orgwrote in
message news:OZWVDQFrHHA.3456@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
If you are using Server.Transfer method or cross-page posting, you can use
PreviousPage property to access the originating page.
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
>
>
<bbawa1@.yahoo.comwrote in message
news:1181585117.479238.102680@.n15g2000prd.googlegr oups.com...
Quote:
Originally Posted by
>I have a web form welcome.asp and it has three textboxes and two
>dropdown list. It has one button called Submit.
>>
>when I click that button it should pass all the data from text boxes
>and dropdown lists to another web form named processform.aspx.
>>
>So, my question is how can I pass the data from one web form to
>another web form by clicking abutton.
>>
>Thanks
>>
>
>
On Jun 11, 12:15 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.orgwrote:
Quote:
Originally Posted by
If you are using Server.Transfer method or cross-page posting, you can use
PreviousPage property to access the originating page.
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin
>
<bba...@.yahoo.comwrote in message
>
news:1181585117.479238.102680@.n15g2000prd.googlegr oups.com...
>
>
>
Quote:
Originally Posted by
I have a web form welcome.asp and it has three textboxes and two
dropdown list. It has one button called Submit.
>
Quote:
Originally Posted by
when I click that button it should pass all the data from text boxes
and dropdown lists to another web form named processform.aspx.
>
Quote:
Originally Posted by
So, my question is how can I pass the data from one web form to
another web form by clicking abutton.
>
Quote:
Originally Posted by
Thanks- Hide quoted text -
>
- Show quoted text -
When I use Server.Transfer["ProcessForm.aspx"]; my btn_click event
it gives me following error message
only assignments, call, increment, decrement, and new object
expressions can be used as a statement
cannot apply indexing with [] to an expression of type 'method group'
Ysgrifennodd bbawa1@.yahoo.com:
Quote:
Originally Posted by
I have a web form welcome.asp and it has three textboxes and two
dropdown list. It has one button called Submit.
>
when I click that button it should pass all the data from text boxes
and dropdown lists to another web form named processform.aspx.
>
So, my question is how can I pass the data from one web form to
another web form by clicking abutton.
>
Thanks
>
I take the view that computer programs are usually modeling some real
world object or objects. I therefore construct server side object(s)
that store information entered via Pages in its/their state variables
(fields/properties/attributes).
On submit, I do any validation of the data that is required, store the
data in the object(s) and then store a reference to the object(s) in the
Session.
It is then a simple matter to retrieve that object and its data from the
Session in any subsequent form.
HTH
Peter
ASP.NET provides a plethora of ways to pass data between pages.
I've detailed virtually every technique here:
http://SteveOrr.net/articles/PassData.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
<bbawa1@.yahoo.comwrote in message
news:1181585117.479238.102680@.n15g2000prd.googlegr oups.com...
Quote:
Originally Posted by
>I have a web form welcome.asp and it has three textboxes and two
dropdown list. It has one button called Submit.
>
when I click that button it should pass all the data from text boxes
and dropdown lists to another web form named processform.aspx.
>
So, my question is how can I pass the data from one web form to
another web form by clicking abutton.
>
Thanks
>
Passing values in QueryStrings and form actions
Despite labouring through a 600 page book I am still baffled by some of the fundamentals. I have a couple of questions.
1) Form Submission
Every example in the book had this tag on the page.
<form id="FormName" runat="server">
By default the form submits to the same page that it the form is on.
How do I make a form submit to another page?
In html/asp this would be ..
<form name="FormName" action="SomeOtherPage.asp" method="get">
2) How do you pass variables in the QueryString?
In ASP this would be:
<form name="FormName" action="SomePage.asp?SomeID=275" method="Get">
and, on SomePage.asp you would access the value of SomeID by writing
SomeID = Request.QueryString("SomeID")
How do you do this in .Net?
Thanks for any help.In asp.net 2.0 you can specify a different page to post the form to if nessecary but you generally never have queryString values in a form action. QueryString values work in the same way > Request.QueryString("SomeID")
One of the main advances in .net is that is "event" driven i.e. on one page you can handle only the specific events you want to like page load, button1 click, button2 click etc when they occur. classic asp could not do this so you posted form info to another page to process it. .net you present the info and send it back to the same page to process.
Once you get the hang of it more complex tasks become easier to code etc.
Just a quick note.
If you are using C#, then it is:
Request.QueryString["SomeID"]
and not
Request.QueryString("SomeID")
Hope that helps!!
Gary
In asp.net 2.0 you can specify a different page to post the form to if nessecary but you generally never have queryString values in a form action. QueryString values work in the same way > Request.QueryString("SomeID")
One of the main advances in .net is that is "event" driven i.e. on one page you can handle only the specific events you want to like page load, button1 click, button2 click etc when they occur. classic asp could not do this so you posted form info to another page to process it. .net you present the info and send it back to the same page to process.
Once you get the hang of it more complex tasks become easier to code etc.
But how do you concatenate the querystring to pass the values. In ASP.net the form tag looks like
<form id="FormID" runat="server">
by default the form submits to the same page it is on. Let's say the page it is on is called Booking.aspx ... how would I make the form submit to Booking.aspx?BookingID=237
Thanks for your reply.
just add the action attribute
<form id="FormID" action="Booking.aspx?BookingID=237" runat="server">
This only works is asp.net 2.0, not 1.1 and I suggest not using querystring values in form action, it defeats the purpose of posting form data. put a textbox or hidden control <asp:hiddenfield id="bookingID" value="123"....etc/>
Posting to another page you can get form data like request.form("bookingID")
post_back to same page would be bookingID.value
just add the action attribute
<form id="FormID" action="Booking.aspx?BookingID=237" runat="server">
This only works is asp.net 2.0, not 1.1 and I suggest not using querystring values in form action, it defeats the purpose of posting form data. put a textbox or hidden control <asp:hiddenfield id="bookingID" value="123"....etc/>
Posting to another page you can get form data like request.form("bookingID")
post_back to same page would be bookingID.value
Thanks for your reply ... but I can't get it to work. (I am using ASP.Net 2.0)
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" action="Login.aspx" runat="server">
<div>
<asp:Label ID="myLabel" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Text="hello"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
When I click the submit button, the form still submits to the page it is on (test.aspx). Why isn't it submitting to Login.aspx?
Thanks again.
Sorry .net sets the form action attribute unless you override it in an inherited class.
You set postBackURL="myPage.aspx" on a button etc.
Ah, that's it. Thanks very much.
Read about cross page postbacks:
http://www.codeproject.com/aspnet/PostToAnotherPage.asp
Passing values to a Series of Dropdown lists on another page...
I know that the simple solution here is a standard page that simple changes a where its looking form the menu, but the higher up that is overseeing the request is die hard agianst the way it looks visually and how it opperates. So what I had to do is create two pages both with a series of 4 dropdownlists that allow selections that get you ultimately to an internal FAQ page.
My question is how can I pass the values of the first page's dropdownlists along to the second page. I created session variable but when I assign the values, I am sure you can guess the error, "Value is not a part of the list..blah, blah, blah". So how can I get the values to match from the previous page's selections?
When you get this error, that means your second page's list doesn't have this value list.
1. Check the session value to make sure your passed value is correct, and is the one in your second page's ddl item list.
2. Add a null ListItem in your second page ddl. catch it to the default selected item if error happens.
Hope it helps
This is exactly what is happening. Is there a way to force the DDL's to complete there SQL which would populate it's lists based on the selection of the previous DDL's value during the Page load event?
Does anyone have any ideas or points in the right direction as to how this can be done. I'm sure it is going to take some extensive coding, but being probably less than a novice and a true "hack" I have no idea where to start.
Gatorzlair:
This is exactly what is happening. Is there a way to force the DDL's to complete there SQL which would populate it's lists based on the selection of the previous DDL's value during the Page load event?
Hi,
Based on my understanding, you want to bind the DropDownLists by the parameters passed from the other page. If I have misunderstood you, please feel free to let me know.
We can bind the DropDownLists by parameters in the Page Load event. First, we need to get the parameters and then get the data source by them to bind the DropDownLists. The following is the simple example:
protected void Page_Load(object sender, EventArgs e) {//Get parameters.string strPara1 = Request.QueryString["Parameter1"];string strPara2 = Request.QueryString["Parameter2"];//Get Data source by the parameters. DataSet ds = GetDataSource(strPara1, strPara2);//Bind DropDownList. DropDownList1.DataSource = ds; DropDownList1.DataTextField ="**"; DropDownList1.DataValueField ="**"; DropDownList1.DataBind(); } I hope this helps.
passing values with request.redirect
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.
passing variable from child to parent - possible ?
press,
then id like the result of the child form to pass data back to the parent -
without losing any data previously entered
on the parent - is this possible ? ( my main parent window is starting to
get quite cluttered)
cheers
markmark wrote:
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
The problem is in not losing the "parent" data... Are these windows open
in the same browser window or are you opening the "child" in a new
window? If its the same just save their existing data, in a
db/viewstate/session/etc, and then when you reload it retrieve it.
If not you will have to force the "parent" to postback to get it to
refresh, and with the viewstate enabled you should get the pre-entered
data to remain
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Mark,
The standard way is to call javascript method showModalDialog for the child
form. The child form can pass back data in javascript window.returnValue
property which the parent form will get as a return value of the
showModalDialog call.
Eliyahu
"mark" <mark@.remove.com> wrote in message
news:1122386021.4716.0@.spandrell.news.uk.clara.net ...
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the
parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
Mark,
The standard way is to call javascript method showModalDialog for the child
form. The child form can pass back data in javascript window.returnValue
property which the parent form will get as a return value of the
showModalDialog call.
Eliyahu
"mark" <mark@.remove.com> wrote in message
news:1122386021.4716.0@.spandrell.news.uk.clara.net ...
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the
parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
> The problem is in not losing the "parent" data... Are these windows open
> in the same browser window or are you opening the "child" in a new
> window? If its the same just save their existing data, in a
> db/viewstate/session/etc, and then when you reload it retrieve it.
> If not you will have to force the "parent" to postback to get it to
> refresh, and with the viewstate enabled you should get the pre-entered
> data to remain
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
looks like ill be forced to save on opening the child, either that i
redesign the whole form to be more modular
problem is - i have to pass an ID to the child that doesnt exist until the
parent is saved - so things are getting more complicated
than in reality they should be
cheers
mark
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OvYQHtekFHA.1464@.TK2MSFTNGP14.phx.gbl...
> Mark,
> The standard way is to call javascript method showModalDialog for the
child
> form. The child form can pass back data in javascript window.returnValue
> property which the parent form will get as a return value of the
> showModalDialog call.
> Eliyahu
got any examples ?
thanks
mark
> The problem is in not losing the "parent" data... Are these windows open
> in the same browser window or are you opening the "child" in a new
> window? If its the same just save their existing data, in a
> db/viewstate/session/etc, and then when you reload it retrieve it.
> If not you will have to force the "parent" to postback to get it to
> refresh, and with the viewstate enabled you should get the pre-entered
> data to remain
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
looks like ill be forced to save on opening the child, either that i
redesign the whole form to be more modular
problem is - i have to pass an ID to the child that doesnt exist until the
parent is saved - so things are getting more complicated
than in reality they should be
cheers
mark
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OvYQHtekFHA.1464@.TK2MSFTNGP14.phx.gbl...
> Mark,
> The standard way is to call javascript method showModalDialog for the
child
> form. The child form can pass back data in javascript window.returnValue
> property which the parent form will get as a return value of the
> showModalDialog call.
> Eliyahu
got any examples ?
thanks
mark
passing variable from child to parent - possible ?
press,
then id like the result of the child form to pass data back to the parent -
without losing any data previously entered
on the parent - is this possible ? ( my main parent window is starting to
get quite cluttered)
cheers
markmark wrote:
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
The problem is in not losing the "parent" data... Are these windows open
in the same browser window or are you opening the "child" in a new
window? If its the same just save their existing data, in a
db/viewstate/session/etc, and then when you reload it retrieve it.
If not you will have to force the "parent" to postback to get it to
refresh, and with the viewstate enabled you should get the pre-entered
data to remain
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
passing variable from child to parent - possible ?
press,
then id like the result of the child form to pass data back to the parent -
without losing any data previously entered
on the parent - is this possible ? ( my main parent window is starting to
get quite cluttered)
cheers
markmark wrote:
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the parent
-
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
>
The problem is in not losing the "parent" data... Are these windows open
in the same browser window or are you opening the "child" in a new
window? If its the same just save their existing data, in a
db/viewstate/session/etc, and then when you reload it retrieve it.
If not you will have to force the "parent" to postback to get it to
refresh, and with the viewstate enabled you should get the pre-entered
data to remain
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Mark,
The standard way is to call javascript method showModalDialog for the child
form. The child form can pass back data in javascript window.returnValue
property which the parent form will get as a return value of the
showModalDialog call.
Eliyahu
"mark" <mark@.remove.com> wrote in message
news:1122386021.4716.0@.spandrell.news.uk.clara.net...
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the
parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
>
> >
> The problem is in not losing the "parent" data... Are these windows open
> in the same browser window or are you opening the "child" in a new
> window? If its the same just save their existing data, in a
> db/viewstate/session/etc, and then when you reload it retrieve it.
> If not you will have to force the "parent" to postback to get it to
> refresh, and with the viewstate enabled you should get the pre-entered
> data to remain
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
looks like ill be forced to save on opening the child, either that i
redesign the whole form to be more modular
problem is - i have to pass an ID to the child that doesnt exist until the
parent is saved - so things are getting more complicated
than in reality they should be
cheers
mark
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OvYQHtekFHA.1464@.TK2MSFTNGP14.phx.gbl...
> Mark,
> The standard way is to call javascript method showModalDialog for the
child
> form. The child form can pass back data in javascript window.returnValue
> property which the parent form will get as a return value of the
> showModalDialog call.
> Eliyahu
>
got any examples ?
thanks
mark
passing variable from Popup
(without a postback on the current page).
I have a form on 'page1' with various text input boxes. One box contains an
image URL. To select the url , the user can click on a browse button to open
a url chooser pop up ('page2'). I want the url that is selected in 'page2'
to be posted back to 'page1' and displayed in the input box, without losing
the values a user has already input in the other textboxes on page1.
I can use the 'previouspage' method, but I don't think this can work with
popups can it? I don't want the user to lose any of the other textboxes if
they have to browse to the url chooser page then return to the page1.
hopefully that all makes sense.
JJyes or I was using:
btn_browse.Attributes.Add("onclick", "java script:window.open('..etc
"Mark Rae" <mark@.markNOSPAMrae.com> wrote in message
news:uJ5DjU0$GHA.3536@.TK2MSFTNGP03.phx.gbl...
> "JJ" <abc@.xyz.com> wrote in message
> news:eEdelQ0$GHA.4680@.TK2MSFTNGP04.phx.gbl...
>
> When you say 'popup', do you mean you're using showModalDialog...?
>
"JJ" <abc@.xyz.com> wrote in message
news:eEdelQ0$GHA.4680@.TK2MSFTNGP04.phx.gbl...
> Whats the best way to pass a variable from a popup to the current page
> (without a postback on the current page).
When you say 'popup', do you mean you're using showModalDialog...?
Write this code, on click event on button leads to close the popup.
/* Start from here*/
String sURL =’’ // selected url
string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage(‘ + sURL
+’); window.opener.document.forms(0).submit();
self.close();</SCRIPT>";
Page.RegisterClientScriptBlock("ClosePopup", strScript);
/* Ends here*/
Declare the this javascript function SendBackURLTOMainPage(val) in the main
page (aspx)
hdnURL is the hidden variable which store the selected URL from the popup
page.
function SendBackURLTOMainPage (val)
{
document.getElementById("hdnURL").innerText = val;
}
all the best,
Lokesh
"JJ" wrote:
> Whats the best way to pass a variable from a popup to the current page
> (without a postback on the current page).
> I have a form on 'page1' with various text input boxes. One box contains a
n
> image URL. To select the url , the user can click on a browse button to op
en
> a url chooser pop up ('page2'). I want the url that is selected in 'page2'
> to be posted back to 'page1' and displayed in the input box, without losin
g
> the values a user has already input in the other textboxes on page1.
> I can use the 'previouspage' method, but I don't think this can work with
> popups can it? I don't want the user to lose any of the other textboxes if
> they have to browse to the url chooser page then return to the page1.
>
> hopefully that all makes sense.
> JJ
>
>
Thanks Lokesh. But is there any way of doing this in ASP.net rather than
javascript?
"Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
> Write this code, on click event on button leads to close the popup.
> /* Start from here*/
> String sURL ='' // selected url
> string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage(' + sURL
> +'); window.opener.document.forms(0).submit();
> self.close();</SCRIPT>";
> Page.RegisterClientScriptBlock("ClosePopup", strScript);
> /* Ends here*/
>
> Declare the this javascript function SendBackURLTOMainPage(val) in the
> main
> page (aspx)
> hdnURL is the hidden variable which store the selected URL from the popup
> page.
> function SendBackURLTOMainPage (val)
> {
> document.getElementById("hdnURL").innerText = val;
> }
> all the best,
> Lokesh
> "JJ" wrote:
>
Also,
If I wanted to pass the variable into different textboxes, (depending on
which 'browse' button was clicked) is there a way of doing this?
JJ
"JJ" <abc@.xyz.com> wrote in message
news:e0Vl2y0$GHA.1464@.TK2MSFTNGP02.phx.gbl...
> Thanks Lokesh. But is there any way of doing this in ASP.net rather than
> javascript?
> "Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
> news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
>
"JJ" <abc@.xyz.com> wrote in message
news:e0Vl2y0$GHA.1464@.TK2MSFTNGP02.phx.gbl...
> Thanks Lokesh. But is there any way of doing this in ASP.net rather than
> javascript?
No. ASP.NET is server-side, and can't obviously open windows client-side -
you need JavaScript for that.
Ok I've been trying to do this but without success:
I have a button on my urlChooser page:
protected void Button1_OnClick(object sender, System.EventArgs e)
{
String sURL = this.ImageURL_txtbox.Text; // selected url
string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage('" + sURL +
"'); window.opener.document.forms(0).submit();self.close();</SCRIPT>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"ClosePopup",
strScript);
}
and the javascript function in my main page is:
<script type="text/javascript">
function SendBackURLTOMainPage (val)
{
document.getElementById('TextBox1').value=val;
}
</script>
However, the urlChooser page comes up with an error when I click the button,
and the urlChooser window doesn't close. The error says there's an invald
character in this line:
<SCRIPT>window.opener.SendBackURLTOMainPage('/WebSite1/Uploads/XPS1/admin2/C
ivic_photo.gif');
window.opener.document.forms(0).submit();self.close();</SCRIPT>
(forgive me but I'm not too familiar with javascript)
JJ
"Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
> Write this code, on click event on button leads to close the popup.
> /* Start from here*/
> String sURL ='' // selected url
> string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage(' + sURL
> +'); window.opener.document.forms(0).submit();
> self.close();</SCRIPT>";
> Page.RegisterClientScriptBlock("ClosePopup", strScript);
> /* Ends here*/
>
> Declare the this javascript function SendBackURLTOMainPage(val) in the
> main
> page (aspx)
> hdnURL is the hidden variable which store the selected URL from the popup
> page.
> function SendBackURLTOMainPage (val)
> {
> document.getElementById("hdnURL").innerText = val;
> }
> all the best,
> Lokesh
> "JJ" wrote:
>
Found the problem, the single quotes need to be double quotes. Sorry. Still
learning...
"JJ" <abc@.xyz.com> wrote in message
news:ObG8i62$GHA.2328@.TK2MSFTNGP02.phx.gbl...
> Ok I've been trying to do this but without success:
> I have a button on my urlChooser page:
> protected void Button1_OnClick(object sender, System.EventArgs e)
> {
> String sURL = this.ImageURL_txtbox.Text; // selected url
> string strScript = "<SCRIPT>window.opener.SendBackURLTOMainPage('" + sURL
> + "'); window.opener.document.forms(0).submit();self.close();</SCRIPT>";
> Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"ClosePopup",
> strScript);
> }
> and the javascript function in my main page is:
> <script type="text/javascript">
> function SendBackURLTOMainPage (val)
> {
> document.getElementById('TextBox1').value=val;
> }
> </script>
>
> However, the urlChooser page comes up with an error when I click the
> button, and the urlChooser window doesn't close. The error says there's an
> invald character in this line:
> <SCRIPT>window.opener.SendBackURLTOMainPage('/WebSite1/Uploads/XPS1/admin2
/Civic_photo.gif');
> window.opener.document.forms(0).submit();self.close();</SCRIPT>
>
> (forgive me but I'm not too familiar with javascript)
>
> JJ
>
>
>
>
>
> "Lokesh Reddy" <Lokesh Reddy@.discussions.microsoft.com> wrote in message
> news:662ECFA3-6669-4DC7-97CF-334B00111516@.microsoft.com...
>
Saturday, March 24, 2012
Passing Variable to XSLT
using to create an export file. Using XslTransform class I have a form
that collects data and executes a stored procedure to pull information
from my SQL Database. I would like to include information from a
textbox on the form in the XSL stylesheet. Can some one please explain
how I can pull information from my code and pass it to the stylesheet?
Thanks
CharlesRead this: http://msdn2.microsoft.com/en-us/library/ts9by56w.aspx
<cbanks@.bjtsupport.com> wrote in message
news:1133885799.818228.237430@.g49g2000cwa.googlegroups.com...
>I have a ASP.NET application written in VB.net 2003 with a form I am
> using to create an export file. Using XslTransform class I have a form
> that collects data and executes a stored procedure to pull information
> from my SQL Database. I would like to include information from a
> textbox on the form in the XSL stylesheet. Can some one please explain
> how I can pull information from my code and pass it to the stylesheet?
> Thanks
> Charles
>
One thing that comes to mind, though I'm sure I'm overcomplicating
it... is to make the XSLT an aspx page (you can specify the
appropriatae content-type in the codebehind) and pass it a query
paramater (MyXslt.xsl.aspx?Id=7). I do this with my ECMAScript
(JavaScript) at times like "GetFirefoxSVGInformation.js.aspx?id=314"
This would work clientside, but should be close on serverside too.
Peter,
Thanks for the quick reply! I'll work with that information.
Charles
Being new to all of this, I need to ask one more question. Once the
variable is passed, how do I insert it into my xslt?
<xsl:for-each select="PrintChecks/tblChecks">
<xsl:text>TRANS CHECK </xsl:text>
<xsl:text></xsl:text><xsl:value-of select="fldFirstName"/>
<xsl:text> </xsl:text><xsl:value-of select="fldLastName"/>
var needs to go here
...
/xsl:for-each
Thanks again.
I was able to figure everything out thanks to the link Peter sent.
Just goes to show ya that a little help from some one in these groups
goes a long way!
Thanks again!
Charles
Wednesday, March 21, 2012
Passing variables in .vb page_load event to .aspx file
In my page_load event of my web form i check against a database to see if a particular record exists and return a boolean.
How do i get my aspx to check that boolean to determine what to display on the screen.?I would have something like:
// pseudo codepage_load()
{
// get from databasebool doesExist = databasecall();
if (doesExist)
continueSuccessfulDraw();
else
continueUnsuccessfulDraw();
}
Does that help?
You can also do this from within the method that handles the page_load event. One option would be to put a Placeholder control on your .aspx page in the location that you'd want to put whatever it is that is dependent on the boolean you are checking -- and then load the specific controls used for display into the Placeholder.
u need to use web controls
based on the value from the database you can set the visible property true/false
can you give some more details like exactly what you want to display?
Passing varuiables to on form to another
I am having trouble passing variables from on form to another. .aspx. I am using a GridView to display the table. The user inputs the LastName they want to look up. Then I want to send that variable for LastName to another form site so they can edit those entities. Oh... all confused!
Try looking into the session object and viewstate.This works... But
*Test.aspx*Sub edit(ByVal SenderAsObject,ByVal EAs EventArgs)
Response.Redirect("Default.aspx?name=" & System.Web.HttpUtility.UrlEncode(LName.Text))
EndSub
*Default.aspx*
Sub Page_Load(ByVal SenderAsObject,ByVal EAs EventArgs)IfNot (Page.IsPostBack)ThenNameLabel.Text = Request.Params(
"LName")EndIfEndSub<formaction="default.aspx"runat="server">Hi
<asp:labelid="NameLabel"runat="server"/>!I can't get it to display. Its in the URL, but its not displaying. Then once i know i got the variable then i want to display a dataform. Thanks Nic
You should check out this webpage:http://blogs.wwwcoder.com/psantry/archive/2004/05/14/398.aspx
If that doesn't help you, maybe you could look into Request.Querystring instead of Request.Params.
Hope this helps.
Modify your code as following:
*Default.aspx*
If Not (Page.IsPostBack) Then
NameLabel.Text = Request.QueryString("name")
End If
I have written a small article relating to passing values between pages. Here is the URL:
Passing values between pages
Check if that helps
PassingValues
C#
protected {Control Class Name} {Control Name on Form};
VB.NET
Protected {Control Name on Form} As {Control Class Name}
Friday, March 16, 2012
Password
password field cant be preloaded
I have a quick question.
I have a webpage allow user to modify his/her information. When I
generate the form, I want to pre-load the information to the
TextBoxes. But for the password (and confirm password) textbox, the
text can't be loaded (the TextBoxes are empty, no "dot" in them). I
checked inside Page_Load the text is loaded, but when the page is
render, the data is flushed.
I read some ASP code that in ASP this won't happen, you just do:
<input type="password" name="vcPassword" value="<%=vcPassword%>"
Please Help
Homa WongYou're not supposed to set the text of a password field from the server
because it's unsecure. That's why it didn't show up; it's prevented as a
security precaution. (The password would be plain text to anybody who views
the source of the page.)
However there is a workaround if you are willing to accept this risk.
Here's the simplest example I've seen:
MyPWTextBox.Attributes.Add("value", strPassWord)
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Homa" <homaneag@.yahoo.com> wrote in message
news:a9a6fc0b.0310201646.1763edf0@.posting.google.c om...
> Hi,
> I have a quick question.
> I have a webpage allow user to modify his/her information. When I
> generate the form, I want to pre-load the information to the
> TextBoxes. But for the password (and confirm password) textbox, the
> text can't be loaded (the TextBoxes are empty, no "dot" in them). I
> checked inside Page_Load the text is loaded, but when the page is
> render, the data is flushed.
> I read some ASP code that in ASP this won't happen, you just do:
> <input type="password" name="vcPassword" value="<%=vcPassword%>">
>
> Please Help
> Homa Wong
You're not supposed to set the text of a password field from the server
because it's unsecure. That's why it didn't show up; it's prevented as a
security precaution. (The password would be plain text to anybody who views
the source of the page.)
However there is a workaround if you are willing to accept this risk.
Here's the simplest example I've seen:
MyPWTextBox.Attributes.Add("value", strPassWord)
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Homa" <homaneag@.yahoo.com> wrote in message
news:a9a6fc0b.0310201646.1763edf0@.posting.google.c om...
> Hi,
> I have a quick question.
> I have a webpage allow user to modify his/her information. When I
> generate the form, I want to pre-load the information to the
> TextBoxes. But for the password (and confirm password) textbox, the
> text can't be loaded (the TextBoxes are empty, no "dot" in them). I
> checked inside Page_Load the text is loaded, but when the page is
> render, the data is flushed.
> I read some ASP code that in ASP this won't happen, you just do:
> <input type="password" name="vcPassword" value="<%=vcPassword%>">
>
> Please Help
> Homa Wong
It's a security issue. If you want your applications to be secure you should
only store hashed password values so you will never be able to know the
original password. And in any case you should not be sending passwords to
anybody, not even the original user.
Jerry
"Homa" <homaneag@.yahoo.com> wrote in message
news:a9a6fc0b.0310201646.1763edf0@.posting.google.c om...
> Hi,
> I have a quick question.
> I have a webpage allow user to modify his/her information. When I
> generate the form, I want to pre-load the information to the
> TextBoxes. But for the password (and confirm password) textbox, the
> text can't be loaded (the TextBoxes are empty, no "dot" in them). I
> checked inside Page_Load the text is loaded, but when the page is
> render, the data is flushed.
> I read some ASP code that in ASP this won't happen, you just do:
> <input type="password" name="vcPassword" value="<%=vcPassword%>">
>
> Please Help
> Homa Wong
It's a security issue. If you want your applications to be secure you should
only store hashed password values so you will never be able to know the
original password. And in any case you should not be sending passwords to
anybody, not even the original user.
Jerry
"Homa" <homaneag@.yahoo.com> wrote in message
news:a9a6fc0b.0310201646.1763edf0@.posting.google.c om...
> Hi,
> I have a quick question.
> I have a webpage allow user to modify his/her information. When I
> generate the form, I want to pre-load the information to the
> TextBoxes. But for the password (and confirm password) textbox, the
> text can't be loaded (the TextBoxes are empty, no "dot" in them). I
> checked inside Page_Load the text is loaded, but when the page is
> render, the data is flushed.
> I read some ASP code that in ASP this won't happen, you just do:
> <input type="password" name="vcPassword" value="<%=vcPassword%>">
>
> Please Help
> Homa Wong
Password Field not getting populated from Database
Any HelpHi,
ASP.NET TexBox just doesn't write out the text when it is in password mode, it's just security precaution. However if you absolutely need such feature, you can wrap it simply in a custom control.
C#
using System;
using System.Web.UI;
using System.Web.UI.WebControls;namespace Joteke.Controls
{
public class MyTextBox : TextBox
{
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender (writer);
if(this.TextMode == TextBoxMode.Password)
{
string text=this.Text;
if(text.Length > 0)
writer.AddAttribute(HtmlTextWriterAttribute.Value,text);
}
}}
}
VB (translated from C# with a tool)
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControlsNamespace Joteke.Controls
Public Class MyTextBox
Inherits TextBoxProtected Overrides Sub AddAttributesToRender(writer As HtmlTextWriter)
MyBase.AddAttributesToRender(writer)If Me.TextMode = TextBoxMode.Password Then
Dim [text] As String = Me.TextIf [text].Length > 0 Then
writer.AddAttribute(HtmlTextWriterAttribute.Value, [text])
End IfEnd If
End Sub 'AddAttributesToRender
End Class 'MyTextBox
End Namespace 'Joteke.Controls
I don't mind that security feature the only problem is that when you go to update a user the password field is blank and if you made no change to the password field then it updates as "" instead of the previous value.
Any solution for this then ?
Well, the password is in the HTML after postback (rendered along with the HTML), that's the only part.
As I said, previous control allows you to prepopulate TextBox even in password mode.
FYI: I blogged this one here.
http://blogs.aspadvice.com/joteke/archive/2005/02/03/2531.aspx
There's also provided the shortcut solution, that is just adding the value to the Attributes collection when you wouldn't need to write a custom control.
Password Fields and Postbacks
We're trying to determine how to deal with password fields losing their
state on a post back.
We've got a form that implements post backs to carry out server side
processing. As a result of the post back, passwords entered by the user
lose their values and the user gets an error message upon final validation
when they submit. Here's an illustration:
1. Password : [ ]
2. Confirm: [ ]
3. Select something from a list: [ ]
// this could cause a post-back, which wipes out the passwords
4. Some other field: [ ]
5. Hit submit key
After hitting the submit key (5), the user gets an error message, because
the passwords are now blank as a result of the post back in step #3. What
techniques should be used to get around this? We've tried fiddling with
the VIEWSTATE, to remember values, but it seems like their should be better
way... (?)
-- dwaThere is a reason why passwords don't survive postbacks, and it's built into
the browser. In fact, if you enter a password into a password field in any
HTML form, navigate away from it, and return to the page using the Back
button, the form fields will all have their values, EXCEPT for the password
fields. Why? To prevent anyone from stealing another person's password by
doing so. Even if you manage to circumvent this, and I can think of one or
two ways you might, are you sure you want to abandon the security that this
affords, which all browser manufacturers seem to think is extremely
important?
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"dwa" <da@.hotmail.com> wrote in message
news:eaI0#Hy#DHA.2520@.TK2MSFTNGP11.phx.gbl...
> All,
> We're trying to determine how to deal with password fields losing their
> state on a post back.
> We've got a form that implements post backs to carry out server side
> processing. As a result of the post back, passwords entered by the user
> lose their values and the user gets an error message upon final validation
> when they submit. Here's an illustration:
> 1. Password : [ ]
> 2. Confirm: [ ]
> 3. Select something from a list: [ ]
> // this could cause a post-back, which wipes out the passwords
> 4. Some other field: [ ]
> 5. Hit submit key
> After hitting the submit key (5), the user gets an error message, because
> the passwords are now blank as a result of the post back in step #3. What
> techniques should be used to get around this? We've tried fiddling with
> the VIEWSTATE, to remember values, but it seems like their should be
better
> way... (?)
> -- dwa