Showing posts with label window. Show all posts
Showing posts with label window. Show all posts

Thursday, March 29, 2012

Passing values between 2 open pages (eg. parent and dialog)

Can someone tell me if there is another way of passing variables back and forth between 2 open pages (such as in the case of a dialog window) without using javascript.

I have done it before using javascript but now that I am using a lot of user controls on my pages I find it a pain in the butt with how the user controls are being named, especially when you have multiple nested controls.

Any help would be greatly appreciated.
Thanks.You could use session variables, but this would require that each of the pages involved do a postback in order to be able to read the session variables. Otherwise, javascript is your best bet.
Alright, thanks mendhak, just thought I would check to see if there was a better way.

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 client and server side (Javascript to C#)

I would like to access client side values from the code behind.

Say I open a window like this

 popWindow = window.open("data_list.aspx","dataWindow",'toolbar,width=150,height=100')
 How can I get the window name "dataWindow" from that current window or the parent window?
 Any other examples accessing variables between server side (C#) and client side (JavaScript) would be greatly appreciated.
 Regards -WH 

Page.Request.ServerVariables["SCRIPT_NAME"] will get the name of the current page. You can also pass values in a querystring, which will make them accessible to server-side code.
thanks, Page.Request.ServerVariables["SCRIPT_NAME"] worked out for me.

Passing Values By javascript

I have two webforms with the names frm1 and frm2. When user hits a button at
the frm1, frm2 opens in a new window. After clicking one row in frm2, this
form is closing.. But i can't pass the values to the frm1 without
postingback frm1. Is ther anyway to pass the values from one WebForm to
another without postingback especially in Javascript?Yes we can use hidden field for that.
sample code
window.opener.document.getElementById("hdAddedSpots").value += ',' +
songId;
window.opener is frm1 that has a hidden field in the name of
"hdAddedSpots".
thanks,
PB
"Alper OZGUR" <alpozgur@.gmail.com> wrote in message
news:OCwAFiTPGHA.668@.TK2MSFTNGP11.phx.gbl...
>I have two webforms with the names frm1 and frm2. When user hits a button
>at the frm1, frm2 opens in a new window. After clicking one row in frm2,
>this form is closing.. But i can't pass the values to the frm1 without
>postingback frm1. Is ther anyway to pass the values from one WebForm to
>another without postingback especially in Javascript?
>
>
Here's an article with links to five different tutorials on how to do what
you need:
http://www.webdevelopersjournal.com...ass_values.html
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Alper OZGUR" <alpozgur@.gmail.com> wrote in message
news:OCwAFiTPGHA.668@.TK2MSFTNGP11.phx.gbl...
>I have two webforms with the names frm1 and frm2. When user hits a button
>at the frm1, frm2 opens in a new window. After clicking one row in frm2,
>this form is closing.. But i can't pass the values to the frm1 without
>postingback frm1. Is ther anyway to pass the values from one WebForm to
>another without postingback especially in Javascript?
>
>
Lot's of thanks to both of you.
"S. Justin Gengo [MCP]" <justin@.[no_spam_please]aboutfortunate.com>, haber
iletisinde unlar yazd:u7Rj1uTPGHA.1696@.TK2MSFTNGP14.phx.gbl...
> Here's an article with links to five different tutorials on how to do what
> you need:
> http://www.webdevelopersjournal.com...ass_values.html
> --
> Sincerely,
> S. Justin Gengo, MCP
> Web Developer / Programmer
> www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
> "Alper OZGUR" <alpozgur@.gmail.com> wrote in message
> news:OCwAFiTPGHA.668@.TK2MSFTNGP11.phx.gbl...
>

Passing Values By javascript

I have two webforms with the names frm1 and frm2. When user hits a button at
the frm1, frm2 opens in a new window. After clicking one row in frm2, this
form is closing.. But i can't pass the values to the frm1 without
postingback frm1. Is ther anyway to pass the values from one WebForm to
another without postingback especially in Javascript?Yes we can use hidden field for that.

sample code
window.opener.document.getElementById("hdAddedSpots").value += ',' +
songId;

window.opener is frm1 that has a hidden field in the name of
"hdAddedSpots".

thanks,
PB

"Alper OZGUR" <alpozgur@.gmail.com> wrote in message
news:OCwAFiTPGHA.668@.TK2MSFTNGP11.phx.gbl...
>I have two webforms with the names frm1 and frm2. When user hits a button
>at the frm1, frm2 opens in a new window. After clicking one row in frm2,
>this form is closing.. But i can't pass the values to the frm1 without
>postingback frm1. Is ther anyway to pass the values from one WebForm to
>another without postingback especially in Javascript?
>
Here's an article with links to five different tutorials on how to do what
you need:

http://www.webdevelopersjournal.com...ass_values.html

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Alper OZGUR" <alpozgur@.gmail.com> wrote in message
news:OCwAFiTPGHA.668@.TK2MSFTNGP11.phx.gbl...
>I have two webforms with the names frm1 and frm2. When user hits a button
>at the frm1, frm2 opens in a new window. After clicking one row in frm2,
>this form is closing.. But i can't pass the values to the frm1 without
>postingback frm1. Is ther anyway to pass the values from one WebForm to
>another without postingback especially in Javascript?
>
Lot's of thanks to both of you.
"S. Justin Gengo [MCP]" <justin@.[no_spam_please]aboutfortunate.com>, haber
iletisinde unlar yazd:u7Rj1uTPGHA.1696@.TK2MSFTNGP14.phx.gbl...
> Here's an article with links to five different tutorials on how to do what
> you need:
> http://www.webdevelopersjournal.com...ass_values.html
> --
> Sincerely,
> S. Justin Gengo, MCP
> Web Developer / Programmer
> www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzsche
> "Alper OZGUR" <alpozgur@.gmail.com> wrote in message
> news:OCwAFiTPGHA.668@.TK2MSFTNGP11.phx.gbl...
>>I have two webforms with the names frm1 and frm2. When user hits a button
>>at the frm1, frm2 opens in a new window. After clicking one row in frm2,
>>this form is closing.. But i can't pass the values to the frm1 without
>>postingback frm1. Is ther anyway to pass the values from one WebForm to
>>another without postingback especially in Javascript?
>>
>>
>>
>>

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 chil pop up to parent

Hello Everyone,
I am trying to pass the value from my child window to my parent window. I
don't get the value from child to my parent when I refresh my parent page,
if I don't refresh my parent page then I get the value frtom my child window
.
Below is the code in my parent window and child page. I need to refresh my
parent page because once the page refreshes and the child window closes, I
want some method to execute
btnSubmit.Attributes.Add("onclick", "window.open('newForm.aspx' ,
'CustomPopUp','width=600, height=400, statusbar=no, menubar=no,
resizable=no') ");
txtName.Text = hdnPopResult.Value; // assigning hidden filed value to a text
filed on asp.net page
my child window
function passvalues()
{
var txtValue = document.getElementById("txtSubmit").value;if(txtValue !="")
{
window.opener.form1.hdnPopResult.value = txtValue;
opener.document.location.reload();
window.close();
}
}
btnSubmit.Attributes.Add("onclick", "passvalues()");
Any help will be apprecaited."Vinki" <Vinki@.discussions.microsoft.com> wrote in message
news:93A10F20-93D0-438B-9BC7-C012DEBAB555@.microsoft.com...

> I am trying to pass the value from my child window to my parent window. I
> don't get the value from child to my parent when I refresh my parent
> page,
> if I don't refresh my parent page then I get the value frtom my child
> window.
That's normal behaviour - think about it...
When you tell a page to reload, that's exactly what it will do i.e. it will
load in precisely the way that it loaded previously - it won't "remember"
the fact that it has been changed client-side *after* it was last loaded...

> I need to refresh my parent page because once the page refreshes and the
> child window closes, I want some method to execute
Is this method client-side or server-side?
Mark Rae
ASP.NET MVP
http://www.markrae.net
you should submit the parent instead of reload.:
window.opener.form1.hdnPopResult.value = txtValue;
window.opener.form1.submit();
-- bruce (sqlwork.com)
Vinki wrote:
> Hello Everyone,
> I am trying to pass the value from my child window to my parent window.
I
> don't get the value from child to my parent when I refresh my parent page
,
> if I don't refresh my parent page then I get the value frtom my child wind
ow.
> Below is the code in my parent window and child page. I need to refresh my
> parent page because once the page refreshes and the child window closes, I
> want some method to execute
> btnSubmit.Attributes.Add("onclick", "window.open('newForm.aspx' ,
> 'CustomPopUp','width=600, height=400, statusbar=no, menubar=no,
> resizable=no') ");
> txtName.Text = hdnPopResult.Value; // assigning hidden filed value to a te
xt
> filed on asp.net page
> my child window
> function passvalues()
> {
> var txtValue = document.getElementById("txtSubmit").value;if(txtValue !=""
)
> {
> window.opener.form1.hdnPopResult.value = txtValue;
> opener.document.location.reload();
> window.close();
>
> }
>
>
> }
> btnSubmit.Attributes.Add("onclick", "passvalues()");
> Any help will be apprecaited.
>
>
It is a server side code.
"Mark Rae [MVP]" wrote:

> "Vinki" <Vinki@.discussions.microsoft.com> wrote in message
> news:93A10F20-93D0-438B-9BC7-C012DEBAB555@.microsoft.com...
>
> That's normal behaviour - think about it...
> When you tell a page to reload, that's exactly what it will do i.e. it wil
l
> load in precisely the way that it loaded previously - it won't "remember"
> the fact that it has been changed client-side *after* it was last loaded..
.
>
> Is this method client-side or server-side?
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
"Vinki" <Vinki@.discussions.microsoft.com> wrote in message
news:EA7EA873-2502-48F0-A12A-A826F6854E4A@.microsoft.com...

> It is a server side code.
Bruce has already given you the correct answer...
Mark Rae
ASP.NET MVP
http://www.markrae.net

Monday, March 26, 2012

Passing values to a pop-up window and de-activating parent window...

Hello All,

How are you guys doing today? Hope all is well.

This is my scenario...

What I want to be able to do is 3 things...first, when I click a hyperlink, I would like to display another aspx page in a pop-up window...second, I need to pass values from the parent window to the child (pop-up) and third...I also would like to deactivate the parent window when the child window is visible! Any guidelines as to how I can accomplish all of this is highly appreciated.

Thanks,

Mohammed

This sounds like something you can do with theASP.NET AJAX Modal Popup window.


You can do this using javascript as well. using window.showModalDialog() and dialogArguments. Here is link to an example:

http://www.java2s.com/Code/JavaScriptReference/Javascript-Methods/showModalDialogExample.htm


Thank you very much for your help Jon. I appreciate you getting back to me.


Hello Darrell,

Appreciate your feedback and thank you for your support.

passing variable to open a new window

I am new to asp.net. I am wondering how I can open a new window from a button or link. I need to pass a value so both windows are linked. I will appreciate any help, code vb.net

The main page has a label is that stores the ID number, I need to pass this value so I can display in the new window information about this id. Please help. Thanks.

use the Querystring to pass variables to other pages

ie.


Response.Redirect("www.myplace.com/mynewpage.aspx?someValue=399393","_blank");

check this out

http://www.codeproject.com/aspnet/QueryString.asp

hth,

mcm


how about javascript?

<asp:button onclientClick='window.open(.....);' Text='Open New Window' runat=server />


Thanks for the answer. However, I need to open a new window. Could you please help me out? I am using vb.net. Thanks.

javascript DOES open a new window.

read about it. -->http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

mcm


You can test the below code in page_load event which will open a new window using javascript

Page.ClientScript.RegisterStartupScript(me.GetType(),"open","window.open('WebForm2.aspx?id=123','','height=400,width=300');",true)

Where WebForm2.aspx is the name of the window you would like to open. Now in webform2 you can get the value of id using

Dim id as String = Request.QueryString("id")

HC


Yes. But I need to pass from the current window, a value which is saved in a label, to the new window. Thanks for the answer.

dim yourPassInVar as string

Page.ClientScript.RegisterStartupScript(me.GetType(),"open","window.open('WebForm2.aspx?id='" + yourPassInVar + ",'','height=400,width=300');",true)

How about this?



In the current window page_load event use the below code if you want the window to open direclty when the page is being loaded

Page.ClientScript.RegisterStartupScript(me.GetType(),"open","window.open('WebForm2.aspx?id=' + '"+Label1.Text+"','','height=400,width=300');",true)

If you want for example to open it on button click event use the below code

Button1.Attributes.Add("onclick","window.open('WebForm2.aspx?id=' + '"+Label1.Text+"','','height=400,width=300');")

Where Button1 is the button you want to open the window when being clicked

HC


Thanks. How can I do it with a button? When clicking on the button, the variable that holds the id value let's say 123 will be passed to webform2.aspx. Again, thanks for the help.

Great. Thank you for all the help!

;-)

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.

Friday, March 16, 2012

Password

Is there an easy way to have a window come up and ask for a password before letting the user get to a form. No user name, just a password. Thanks.you'd have to use forms authentication, as far as i know. I cant think of any way to do that without it... if you made just a password page, and coded an if clause that said if the password is correct, response.redirect to the right page, there would be nothing to stop someone from just going straight to the page...hmmm, maybe you could do that and just check on the page to see if the user is authenticated, i'll get back to you in 10 or 15 min