Hello. I'm a rookie ASP VBScripter and am having a difficult time scripting
the following scenario:
I have an index.asp file that has a multi-line text box and a button of type
button. When the button is clicked a window is spawned with change.asp as
its source. There is a form with a few text boxes and with a button of type
submit and a cancel button of type button that just closes the window. What
I want to happen is I want the information entered in change.asp to be added
into the multi-line text box in index.asp when the submit button is clicked
in change.asp. Here are the index.asp and change.asp files:
//--index.asp----
<html>
<head>
<title>Product Listing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head
<script language="JavaScript" type="text/javascript">
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight );
function changeInfo()
{
var x = (screen.width - 400) / 2;
var y = (screen.height - 320) / 2;
var myWin = window.open("change.asp",null,"scrollbars=no, toolbar=no,
resizable=no, width=400, height=300, left="+x+" top="+y)
}
</script
<body>
<table width="554" cellpadding="5">
<tr>
<td width="400"><img src="http://pics.10026.com/?src=images/HouseValue 031.jpg" width="400"
height="300"></td>
<td width="3027" valign="top"><form name = "picInfo" id = "picInfo">
<textarea name="txtInfo" id="txtInfo" cols="40" rows="10"
wrap="soft" readonly>Press "Change" to enter information.</textarea>
<br>
<input type="button" value="Change" id="btnChange" name="btnChange"
onClick="javascript:changeInfo()">
</form></td>
</tr>
</table>
</body>
</html>
//-----------
//---change.asp------
<html>
<head>
<title>Edit Product Description</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript" type="text/javascript">
function Cancel()
{
window.close();
}
</script>
<body>
<form name="frmChange" id="frmChange" method="post">
<table>
<tr>
<td align="right">Product Name:</td>
<td align="left"><input type="text" name="txtProduct" id="txtProduct"
size="40"></td>
</tr>
<tr>
<td align="right">Model #:</td>
<td align="left"><input type="text" name="txtModel" id="txtModel"
size="40"></td>
</tr>
<tr>
<td align="right">Value:</td>
<td align="left"><input type="text" name="txtValue" id="txtValue"></td>
</tr>
<tr>
<td align="right">Category:</td>
<td align="left"><select name="mnuCategory" id="mnuCategory">
<option selected value="NULL">Choose category...</option>
<option value="Furniture">Furniture</option>
<option value="Electronics">Electronics</option>
<option value="Home Media">Home Media</option>
<option value="Jewlery">Jewlery</option>
</select></td>
</tr>
<tr>
<td align="right" valign="top">Misc. Information:</td>
<td align="left"><textarea name="txtMisc" id="txtMisc" cols="30"
rows="5"></textarea></td>
</tr>
</table>
<br>
<center>
<input type="submit" name="btnSubmitChanges" id="btnSubmitChanges"
value="Submit">
<input type="button" name="btnCancel" id="btnCancel" value="Cancel"
onClick="javascript:Cancel()">
</center>
</form>
</body>
</html>
//--------
I've been messing with it for a day now and I have been unable to pass
variables from change.asp into index.asp. Any help would be much
appreciated.
~Les PeabodySounds like you'll be needing to use some client side javascript.
You can open a new window using javascript such as this:
a=window.open('MyPage.aspx','_new')
There are all kinds of options for setting window properties such as window
size and toolbar visibility.
Here's more info:
http://msdn.microsoft.com/workshop/...hods/open_0.asp
From that new window you can reference the original parent window with
this javascript reference:
Here's an example:
window.opener.document.form1.mytextbox.value = 'whatever';
Here's more info:
http://www.mozilla.org/docs/dom/dom...ndow_ref77.html
--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Les Peabody" <les.peabody@.geo-sync.com> wrote in message
news:eGyXyv62DHA.1184@.TK2MSFTNGP10.phx.gbl...
> Hello. I'm a rookie ASP VBScripter and am having a difficult time
scripting
> the following scenario:
> I have an index.asp file that has a multi-line text box and a button of
type
> button. When the button is clicked a window is spawned with change.asp as
> its source. There is a form with a few text boxes and with a button of
type
> submit and a cancel button of type button that just closes the window.
What
> I want to happen is I want the information entered in change.asp to be
added
> into the multi-line text box in index.asp when the submit button is
clicked
> in change.asp. Here are the index.asp and change.asp files:
> //--index.asp----
> <html>
> <head>
> <title>Product Listing</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> <script language="JavaScript" type="text/javascript">
> self.moveTo(0,0);
> self.resizeTo(screen.availWidth,screen.availHeight );
> function changeInfo()
> {
> var x = (screen.width - 400) / 2;
> var y = (screen.height - 320) / 2;
> var myWin = window.open("change.asp",null,"scrollbars=no, toolbar=no,
> resizable=no, width=400, height=300, left="+x+" top="+y)
> }
> </script>
> <body>
> <table width="554" cellpadding="5">
> <tr>
> <td width="400"><img src="http://pics.10026.com/?src=images/HouseValue 031.jpg" width="400"
> height="300"></td>
> <td width="3027" valign="top"><form name = "picInfo" id = "picInfo">
> <textarea name="txtInfo" id="txtInfo" cols="40" rows="10"
> wrap="soft" readonly>Press "Change" to enter information.</textarea>
> <br>
> <input type="button" value="Change" id="btnChange" name="btnChange"
> onClick="javascript:changeInfo()">
> </form></td>
> </tr>
> </table>
> </body>
> </html>
> //-----------
> //---change.asp------
> <html>
> <head>
> <title>Edit Product Description</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> <script language="JavaScript" type="text/javascript">
> function Cancel()
> {
> window.close();
> }
> </script>
> <body>
> <form name="frmChange" id="frmChange" method="post">
> <table>
> <tr>
> <td align="right">Product Name:</td>
> <td align="left"><input type="text" name="txtProduct" id="txtProduct"
> size="40"></td>
> </tr>
> <tr>
> <td align="right">Model #:</td>
> <td align="left"><input type="text" name="txtModel" id="txtModel"
> size="40"></td>
> </tr>
> <tr>
> <td align="right">Value:</td>
> <td align="left"><input type="text" name="txtValue" id="txtValue"></td>
> </tr>
> <tr>
> <td align="right">Category:</td>
> <td align="left"><select name="mnuCategory" id="mnuCategory">
> <option selected value="NULL">Choose category...</option>
> <option value="Furniture">Furniture</option>
> <option value="Electronics">Electronics</option>
> <option value="Home Media">Home Media</option>
> <option value="Jewlery">Jewlery</option>
> </select></td>
> </tr>
> <tr>
> <td align="right" valign="top">Misc. Information:</td>
> <td align="left"><textarea name="txtMisc" id="txtMisc" cols="30"
> rows="5"></textarea></td>
> </tr>
> </table>
> <br>
> <center>
> <input type="submit" name="btnSubmitChanges" id="btnSubmitChanges"
> value="Submit">
> <input type="button" name="btnCancel" id="btnCancel" value="Cancel"
> onClick="javascript:Cancel()">
> </center>
> </form>
> </body>
> </html>
> //--------
> I've been messing with it for a day now and I have been unable to pass
> variables from change.asp into index.asp. Any help would be much
> appreciated.
> ~Les Peabody
That worked great, I figured there would be a way to access the parent
window. Thanks Steve.
~Les Peabody
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:%23tVzF162DHA.1752@.tk2msftngp13.phx.gbl...
> Sounds like you'll be needing to use some client side javascript.
> You can open a new window using javascript such as this:
> a=window.open('MyPage.aspx','_new')
> There are all kinds of options for setting window properties such as
window
> size and toolbar visibility.
> Here's more info:
http://msdn.microsoft.com/workshop/...hods/open_0.asp
> From that new window you can reference the original parent window with
> this javascript reference:
> Here's an example:
> window.opener.document.form1.mytextbox.value = 'whatever';
> Here's more info:
> http://www.mozilla.org/docs/dom/dom...ndow_ref77.html
> --
> I hope this helps,
> Steve C. Orr, MCSD
> http://Steve.Orr.net
> Hire top-notch developers at http://www.able-consulting.com
>
> "Les Peabody" <les.peabody@.geo-sync.com> wrote in message
> news:eGyXyv62DHA.1184@.TK2MSFTNGP10.phx.gbl...
> > Hello. I'm a rookie ASP VBScripter and am having a difficult time
> scripting
> > the following scenario:
> > I have an index.asp file that has a multi-line text box and a button of
> type
> > button. When the button is clicked a window is spawned with change.asp
as
> > its source. There is a form with a few text boxes and with a button of
> type
> > submit and a cancel button of type button that just closes the window.
> What
> > I want to happen is I want the information entered in change.asp to be
> added
> > into the multi-line text box in index.asp when the submit button is
> clicked
> > in change.asp. Here are the index.asp and change.asp files:
> > //--index.asp----
> > <html>
> > <head>
> > <title>Product Listing</title>
> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> > </head>
> > <script language="JavaScript" type="text/javascript">
> > self.moveTo(0,0);
> > self.resizeTo(screen.availWidth,screen.availHeight );
> > function changeInfo()
> > {
> > var x = (screen.width - 400) / 2;
> > var y = (screen.height - 320) / 2;
> > var myWin = window.open("change.asp",null,"scrollbars=no, toolbar=no,
> > resizable=no, width=400, height=300, left="+x+" top="+y)
> > }
> > </script>
> > <body>
> > <table width="554" cellpadding="5">
> > <tr>
> > <td width="400"><img src="http://pics.10026.com/?src=images/HouseValue 031.jpg" width="400"
> > height="300"></td>
> > <td width="3027" valign="top"><form name = "picInfo" id = "picInfo">
> > <textarea name="txtInfo" id="txtInfo" cols="40" rows="10"
> > wrap="soft" readonly>Press "Change" to enter information.</textarea>
> > <br>
> > <input type="button" value="Change" id="btnChange" name="btnChange"
> > onClick="javascript:changeInfo()">
> > </form></td>
> > </tr>
> > </table>
> > </body>
> > </html>
> > //-----------
> > //---change.asp------
> > <html>
> > <head>
> > <title>Edit Product Description</title>
> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> > </head>
> > <script language="JavaScript" type="text/javascript">
> > function Cancel()
> > {
> > window.close();
> > }
> > </script>
> > <body>
> > <form name="frmChange" id="frmChange" method="post">
> > <table>
> > <tr>
> > <td align="right">Product Name:</td>
> > <td align="left"><input type="text" name="txtProduct" id="txtProduct"
> > size="40"></td>
> > </tr>
> > <tr>
> > <td align="right">Model #:</td>
> > <td align="left"><input type="text" name="txtModel" id="txtModel"
> > size="40"></td>
> > </tr>
> > <tr>
> > <td align="right">Value:</td>
> > <td align="left"><input type="text" name="txtValue" id="txtValue"></td>
> > </tr>
> > <tr>
> > <td align="right">Category:</td>
> > <td align="left"><select name="mnuCategory" id="mnuCategory">
> > <option selected value="NULL">Choose category...</option>
> > <option value="Furniture">Furniture</option>
> > <option value="Electronics">Electronics</option>
> > <option value="Home Media">Home Media</option>
> > <option value="Jewlery">Jewlery</option>
> > </select></td>
> > </tr>
> > <tr>
> > <td align="right" valign="top">Misc. Information:</td>
> > <td align="left"><textarea name="txtMisc" id="txtMisc" cols="30"
> > rows="5"></textarea></td>
> > </tr>
> > </table>
> > <br>
> > <center>
> > <input type="submit" name="btnSubmitChanges" id="btnSubmitChanges"
> > value="Submit">
> > <input type="button" name="btnCancel" id="btnCancel" value="Cancel"
> > onClick="javascript:Cancel()">
> > </center>
> > </form>
> > </body>
> > </html>
> > //--------
> > I've been messing with it for a day now and I have been unable to pass
> > variables from change.asp into index.asp. Any help would be much
> > appreciated.
> > ~Les Peabody
Showing posts with label index. Show all posts
Showing posts with label index. Show all posts
Saturday, March 24, 2012
Wednesday, March 21, 2012
passing variables from page to control
I have a simple index.aspx page that declares and sets a sectionID in the
Page_Load. The in a user control later on in the page, I read the sectionID
variable (in the control's Page_Load) to determine which panel to show. It
does not work
"Name 'sectionID' is not declared" is my error while compiling the user
control.
What am I doing wrong?
This is in my main page's Page_Load
Dim sectionID As String = "about"
--
This is in my user control's Page_Load
If sectionID = "about" Then
pnlAbout.Visible = True
ElseIf sectionID = "home" Then
pnlHome.Visible = True
End If
_____
DC GMake a public property or method on your control that accepts the value from
your page. Something like this:
Public Sub SetSection(Section as Integer)
'Now I have the value I need
End Sub
The from your page, call it like this to pass the value along:
MyControlName.SetSectionID(sectionID)
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"DC Gringo" <dcgringo@.visiontechnology.net> wrote in message
news:OHsJ5uBREHA.2876@.TK2MSFTNGP09.phx.gbl...
> I have a simple index.aspx page that declares and sets a sectionID in the
> Page_Load. The in a user control later on in the page, I read the
sectionID
> variable (in the control's Page_Load) to determine which panel to show.
It
> does not work
> "Name 'sectionID' is not declared" is my error while compiling the user
> control.
> What am I doing wrong?
>
> This is in my main page's Page_Load
> Dim sectionID As String = "about"
> --
>
> This is in my user control's Page_Load
> If sectionID = "about" Then
> pnlAbout.Visible = True
> ElseIf sectionID = "home" Then
> pnlHome.Visible = True
> End If
>
> _____
> DC G
>
Page_Load. The in a user control later on in the page, I read the sectionID
variable (in the control's Page_Load) to determine which panel to show. It
does not work
"Name 'sectionID' is not declared" is my error while compiling the user
control.
What am I doing wrong?
This is in my main page's Page_Load
Dim sectionID As String = "about"
--
This is in my user control's Page_Load
If sectionID = "about" Then
pnlAbout.Visible = True
ElseIf sectionID = "home" Then
pnlHome.Visible = True
End If
_____
DC GMake a public property or method on your control that accepts the value from
your page. Something like this:
Public Sub SetSection(Section as Integer)
'Now I have the value I need
End Sub
The from your page, call it like this to pass the value along:
MyControlName.SetSectionID(sectionID)
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"DC Gringo" <dcgringo@.visiontechnology.net> wrote in message
news:OHsJ5uBREHA.2876@.TK2MSFTNGP09.phx.gbl...
> I have a simple index.aspx page that declares and sets a sectionID in the
> Page_Load. The in a user control later on in the page, I read the
sectionID
> variable (in the control's Page_Load) to determine which panel to show.
It
> does not work
> "Name 'sectionID' is not declared" is my error while compiling the user
> control.
> What am I doing wrong?
>
> This is in my main page's Page_Load
> Dim sectionID As String = "about"
> --
>
> This is in my user control's Page_Load
> If sectionID = "about" Then
> pnlAbout.Visible = True
> ElseIf sectionID = "home" Then
> pnlHome.Visible = True
> End If
>
> _____
> DC G
>
Subscribe to:
Posts (Atom)