Thursday, March 29, 2012

pop up windows

Hi!

I have programmed in Java and Windows form but very new to ASP and web in general. It is very primitive question but currently, I do not know. I want a small pop up windows with close or the like button that will appear when I click on a button. In Java or NET, you can use show method but in ASP or Webmatrix in particular, what component should I use .

Regards.Hello, check my BLOG, I have an article on how to pop up a window from inside ASP.NET

regards
I'm sure haidar's blog shows the proper method - but to help clear up for future knowledge..
Popping up a web page is a client-side event. The .Net server can't feed a popup to your browser- think of all the uncontrollable popups that would occur if the server-side could do this. opening a popup is a clients-ide event using javascript (window.open method)
Hope that helps - and it's a common question - understanding what events are client-side and what are server-side will help avoid confusion
Of course the contents of the popup can be totally designed (perhaps as a web user control) on the server side from within .NET and then merely instanciated in the javascipt. This gives full access to all of the .NET design environment features for the pop-up.

ps: I have not read the blog entry, so that *may* how it is done there also...
Hi!

I use Javascript but as very primitive programmer, I just am able to have this code:

<a onclick="window.open('materialchecking.aspx textbox=txtStartDate','cal','width=250,height=225,left=270,top=180')" href="http://links.10026.com/?link=javascript:;">
<input type="button" value="Check" /></a
It works fine as static page. However, what if I want to transfer some variable value from main page to the pop up windows to do the checking or other way around, do ing some data processing when button is clicked and transfer the result in to the pop up. I guess, there should be other approach as the href is perhaps too simple to do that.

Regards.
Hello, please check my BLOG below, I have an article on how to pop up windows inside asp.net

regards
Sorry!

I did not go to Pop up before and just went to your personal website and could not see the article (!1).

OK. But now question is that I want to transfer some data between master page and pop up windows. How is it possible. Suppose pop up windows is to show the number of stock in record and in store is not different. So when button is clicked, I have top go to server-side database to do something and finally transfer thw TWO number to the pop up. So how to do that.

Thank you so much for your attention.
ok, you might use the Querystring to pass values to the child window

regards
Hi!

I would really appreaciate if you can show me a bit of code to pass A VALUE to child windows.

Regards.
using function in blog...


*************************************
Javascript pop up window script
*************************************
<SCRIPT TYPE="text/javascript">
<!--
function popupform(myform, url, windowname)
{
// don't allow if we don't have the focus
if (! window.focus)return true;

// open the new window,
window.open(url, windowname, 'width=250,height=225,left=270,top=180,scrollbars=yes');
myform.target=windowname;
return true;
}
//-->
</SCRIPT>

then in your link...


<a onclick="popupform(this,'materialchecking.aspx?id='+ document.getElementById('textbox1').value,'cal')" href="http://links.10026.com/?link=javascript:"><input type="button" value="Check" /></a>
</body>
<input type="button" value="Check" /></a>

one of many ways probably .......

HTH
Hi!

Please forgive me if I apprea to be a bit dump. I am quite new to the field. As far as I understand, the call: document.getElementById is to set the value of textbox 1 to cal var. So in the pop up page, which command I should use to EXTRACT that value for use.
In MSDN page, i says that we can pass a colection of value. That is fine, Juts search var by id inb Collection. But I mean what command to EXTRACT those value in the page after we pass that value in the open up command.

To help make it clear, suppose I have an page asking for the invoice number. As within an invoice, there can be many materials with different quantity and price so I decide that after use enter the Supplier and Invoice number, user will be presented with Pop up windows that has text box and dropdownlist to enter list of data. But in this Pop up windows , the Supplier name and invoice name shold be present. I am looking for way to show the Suplier name and Invoice number on the Pop up windows.

Thank you very much for your attention.
in the example - the id of the invoice is being passed using "querystring"
if you look up at the address of this forum page- you will see "?tabindex=1&PostID=782635&mode=flat"
or something like that - this is called the querystring. It is passed as part of the url the client is requesting. In this example there are 3 things being passed - tabindex,postid, and mode
On the page being called- you can access theses values by using

dim myPostID as string
dim myTabIndex as string
dim myMode as string

myPostID = request.querystring("tabindex")
myTabIndex = request.querystring("PostID")
myMode = request.querystring("mode")

then i can use this any way i need to such as..
Sub Page_Load()
dim mySQL as string="Select * from posts WHERE PostId=" & MyPostID
....................

not exact code - but you get the idea

if on the first page, you already hace the supplier and invoice number - then you can pass that in the querystring as such

a onclick="popupform(this,'materialchecking.aspx?Supplier='+ document.getElementById('textbox1').value+ "&Invoice=" + document.getElementById('textbox2').value,'mypopupwindow_name')"

on the recieving page materialchecking.aspx - you would use

Sub Page_Load()
dim MySupplier as string = request.querystrin("Supplier")
dim MyInvoice as string = request.querystrin("Invoice")

HTH
Thank you uncleb1

They all work now. Apart from "&Invoice=" I have to change to '&Invoice' (!!!!cheer), all work and I learn a lot from this doing. Thank you
Hi again!

Now there is more challenge. Suppose I have an textbox that must be filled. I use RequiredValidator. Problem is that with "normal" button, I can write the code for validator but I do not know how for the ´button, created with javascript. Basically, the Pop up windows only works if textbox is not empty.
if you used this function


<SCRIPT TYPE="text/javascript">
<!--
function popupform(myform, url, windowname)
{
// don't allow if we don't have the focus

if (! window.focus)return true;
// open the new window,
window.open(url, windowname, 'width=250,height=225,left=270,top=180,scrollbars=yes');
myform.target=windowname;
return true;
}
//-->
</script>
......... you have a place to check for null

<SCRIPT TYPE="text/javascript">
<!--
function popupform(myform, url, windowname)
{

// don't allow if textbox is blank
if documet.getElementById(textbox1).value="" return true;

// don't allow if we don't have the focus
if (! window.focus)return true;
// open the new window,
window.open(url, windowname, 'width=250,height=225,left=270,top=180,scrollbars=yes');
myform.target=windowname;
return true;
}
//-->
</script>

or you could use a serverside asp textbox and use the built in asp validation - check out this tutorial
http://www.dotnetjunkies.com/QuickStart/aspplus/default.aspx?url=/quickstart/aspplus/doc/webvalidation.aspx

HTH

0 comments:

Post a Comment