By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,334 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,334 IT Pros & Developers. It's quick & easy.

Modal Forms Question in Web Application

P: n/a
Not really sure if this is a javascript problem or C# - sorry if in
wrong place.

Modal Forms Question in Web Application
I have two web forms: Form1 and Form2

Form1 calls Form2 using showModalDialog

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("Form2.aspx",null, WinSettings);
Form2 has a ListBox, a Label and a Button. The listbox is populated
from a sql call to the database. The "SelectedIndexChanged" event
changes the text appearing on the label to the value associated from
the ListBox. The Button closes the form and returns the text from the
label. Form2 works properly when ran by itself.

However, when I load it using showModalDialog from Form1, the first
time the "SelectedIndexChanged" event fires, a new window opens up of
class Form2 rather than just changing the text in the Label field.

Any help would be appreciated.

-------------Form2 Code Behind-----------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EnterpriseObjects;
using StoreObjects;
using System.Data.SqlClient;

using System.Configuration;

namespace ASPNET.StarterKit.Portal
{
public class Form2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblArticleView;
protected DataView dvp;
protected System.Web.UI.WebControls.ListBox ListBox1;
protected DataSet asas;

private void Page_Load(object sender, System.EventArgs e)
{
EnterpriseApplication.Application.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"].ToString();
System.Data.SqlClient.SqlConnection connection = new
System.Data.SqlClient.SqlConnection(EnterpriseAppl ication.Application.Connec
tionString);
asas = new DataSet();
SqlDataAdapter ad;
ad = new SqlDataAdapter("Select * from Store_Articles", connection);
ad.Fill(asas, "Table");
dvp = new DataView(asas.Tables["Table"]);

if(!(Page.IsPostBack))
{
dvp.Sort = "SortOrder";
ListBox1.DataSource = dvp;
ListBox1.DataMember = "Table";
ListBox1.DataValueField = "ArticleID";
ListBox1.DataTextField = "Name";
ListBox1.DataBind();
}
}

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.ListBox1.SelectedIndexChanged += new
System.EventHandler(this.ListBox1_SelectedIndexCha nged);
this.Load += new System.EventHandler(this.Page_Load);
}

private void ListBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
dvp.RowFilter = "ArticleID = '" + ListBox1.SelectedValue.ToString() +
"'";
lblArticleView.Text = dvp[0].Row["Text"].ToString();
}
}
}
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Every time you do a postback in a modal dialog it opens a new windows. I am
not sure why that happens, but there is a way to get around it. Instead of
calling the pop-up page, you will need to create an 'interim' .asp or .htm
page set up as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Add New Ship To</title>
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body MS_POSITIONING="FlowLayout">
<IFRAME width='100%' height='100%' NAME="Frame1" SRC="<popuppage.aspx">
</IFRAME>
</body>
</html>

By having the popuppage in an Iframe and using the this 'interim' page as
the direct call from the javascript ShowModalDialog as follows:

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("interimpage.html",null, WinSettings);

This will eliminate the opening of a new window when the popuppage
refreshes.

Let me know if you have any other questions!

Thanks!

Jim

"news" <me*******@yahoo.com> wrote in message
news:xT*****************@newsread3.news.atl.earthl ink.net...
Not really sure if this is a javascript problem or C# - sorry if in
wrong place.

Modal Forms Question in Web Application
I have two web forms: Form1 and Form2

Form1 calls Form2 using showModalDialog

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("Form2.aspx",null, WinSettings);
Form2 has a ListBox, a Label and a Button. The listbox is populated
from a sql call to the database. The "SelectedIndexChanged" event
changes the text appearing on the label to the value associated from
the ListBox. The Button closes the form and returns the text from the
label. Form2 works properly when ran by itself.

However, when I load it using showModalDialog from Form1, the first
time the "SelectedIndexChanged" event fires, a new window opens up of
class Form2 rather than just changing the text in the Label field.

Any help would be appreciated.

-------------Form2 Code Behind-----------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EnterpriseObjects;
using StoreObjects;
using System.Data.SqlClient;

using System.Configuration;

namespace ASPNET.StarterKit.Portal
{
public class Form2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblArticleView;
protected DataView dvp;
protected System.Web.UI.WebControls.ListBox ListBox1;
protected DataSet asas;

private void Page_Load(object sender, System.EventArgs e)
{
EnterpriseApplication.Application.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"].ToString();
System.Data.SqlClient.SqlConnection connection = new
System.Data.SqlClient.SqlConnection(EnterpriseAppl ication.Application.Connec tionString);
asas = new DataSet();
SqlDataAdapter ad;
ad = new SqlDataAdapter("Select * from Store_Articles", connection);
ad.Fill(asas, "Table");
dvp = new DataView(asas.Tables["Table"]);

if(!(Page.IsPostBack))
{
dvp.Sort = "SortOrder";
ListBox1.DataSource = dvp;
ListBox1.DataMember = "Table";
ListBox1.DataValueField = "ArticleID";
ListBox1.DataTextField = "Name";
ListBox1.DataBind();
}
}

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.ListBox1.SelectedIndexChanged += new
System.EventHandler(this.ListBox1_SelectedIndexCha nged);
this.Load += new System.EventHandler(this.Page_Load);
}

private void ListBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
dvp.RowFilter = "ArticleID = '" + ListBox1.SelectedValue.ToString() +
"'";
lblArticleView.Text = dvp[0].Row["Text"].ToString();
}
}
}

Nov 15 '05 #2

P: n/a
Hi

Or try using
<base target="_self">

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"James Radke" <jr*****@wi.rr.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Every time you do a postback in a modal dialog it opens a new windows. I am not sure why that happens, but there is a way to get around it. Instead of calling the pop-up page, you will need to create an 'interim' .asp or .htm
page set up as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Add New Ship To</title>
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body MS_POSITIONING="FlowLayout">
<IFRAME width='100%' height='100%' NAME="Frame1" SRC="<popuppage.aspx">
</IFRAME>
</body>
</html>

By having the popuppage in an Iframe and using the this 'interim' page as
the direct call from the javascript ShowModalDialog as follows:

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("interimpage.html",null, WinSettings);

This will eliminate the opening of a new window when the popuppage
refreshes.

Let me know if you have any other questions!

Thanks!

Jim

"news" <me*******@yahoo.com> wrote in message
news:xT*****************@newsread3.news.atl.earthl ink.net...
Not really sure if this is a javascript problem or C# - sorry if in
wrong place.

Modal Forms Question in Web Application
I have two web forms: Form1 and Form2

Form1 calls Form2 using showModalDialog

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("Form2.aspx",null, WinSettings);
Form2 has a ListBox, a Label and a Button. The listbox is populated
from a sql call to the database. The "SelectedIndexChanged" event
changes the text appearing on the label to the value associated from
the ListBox. The Button closes the form and returns the text from the
label. Form2 works properly when ran by itself.

However, when I load it using showModalDialog from Form1, the first
time the "SelectedIndexChanged" event fires, a new window opens up of
class Form2 rather than just changing the text in the Label field.

Any help would be appreciated.

-------------Form2 Code Behind-----------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EnterpriseObjects;
using StoreObjects;
using System.Data.SqlClient;

using System.Configuration;

namespace ASPNET.StarterKit.Portal
{
public class Form2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblArticleView;
protected DataView dvp;
protected System.Web.UI.WebControls.ListBox ListBox1;
protected DataSet asas;

private void Page_Load(object sender, System.EventArgs e)
{
EnterpriseApplication.Application.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"].ToString();
System.Data.SqlClient.SqlConnection connection = new

System.Data.SqlClient.SqlConnection(EnterpriseAppl ication.Application.Connec
tionString);
asas = new DataSet();
SqlDataAdapter ad;
ad = new SqlDataAdapter("Select * from Store_Articles", connection);
ad.Fill(asas, "Table");
dvp = new DataView(asas.Tables["Table"]);

if(!(Page.IsPostBack))
{
dvp.Sort = "SortOrder";
ListBox1.DataSource = dvp;
ListBox1.DataMember = "Table";
ListBox1.DataValueField = "ArticleID";
ListBox1.DataTextField = "Name";
ListBox1.DataBind();
}
}

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.ListBox1.SelectedIndexChanged += new
System.EventHandler(this.ListBox1_SelectedIndexCha nged);
this.Load += new System.EventHandler(this.Page_Load);
}

private void ListBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
dvp.RowFilter = "ArticleID = '" + ListBox1.SelectedValue.ToString() +
"'";
lblArticleView.Text = dvp[0].Row["Text"].ToString();
}
}
}


Nov 15 '05 #3

P: n/a
Where would you use that? In the popup page itself? Then you wouldn't need
the separate .htm or .asp page?

Jim

"Vidar Petursson" <th**************************@icysoft.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Or try using
<base target="_self">

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"James Radke" <jr*****@wi.rr.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Every time you do a postback in a modal dialog it opens a new windows. I
am
not sure why that happens, but there is a way to get around it. Instead

of
calling the pop-up page, you will need to create an 'interim' .asp or ..htm page set up as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Add New Ship To</title>
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body MS_POSITIONING="FlowLayout">
<IFRAME width='100%' height='100%' NAME="Frame1" SRC="<popuppage.aspx">
</IFRAME>
</body>
</html>

By having the popuppage in an Iframe and using the this 'interim' page as the direct call from the javascript ShowModalDialog as follows:

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("interimpage.html",null, WinSettings);
This will eliminate the opening of a new window when the popuppage
refreshes.

Let me know if you have any other questions!

Thanks!

Jim

"news" <me*******@yahoo.com> wrote in message
news:xT*****************@newsread3.news.atl.earthl ink.net...
Not really sure if this is a javascript problem or C# - sorry if in
wrong place.

Modal Forms Question in Web Application
I have two web forms: Form1 and Form2

Form1 calls Form2 using showModalDialog

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("Form2.aspx",null, WinSettings);
Form2 has a ListBox, a Label and a Button. The listbox is populated
from a sql call to the database. The "SelectedIndexChanged" event
changes the text appearing on the label to the value associated from
the ListBox. The Button closes the form and returns the text from the
label. Form2 works properly when ran by itself.

However, when I load it using showModalDialog from Form1, the first
time the "SelectedIndexChanged" event fires, a new window opens up of
class Form2 rather than just changing the text in the Label field.

Any help would be appreciated.

-------------Form2 Code Behind-----------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EnterpriseObjects;
using StoreObjects;
using System.Data.SqlClient;

using System.Configuration;

namespace ASPNET.StarterKit.Portal
{
public class Form2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblArticleView;
protected DataView dvp;
protected System.Web.UI.WebControls.ListBox ListBox1;
protected DataSet asas;

private void Page_Load(object sender, System.EventArgs e)
{
EnterpriseApplication.Application.ConnectionString =
ConfigurationSettings.AppSettings["ConnectionString"].ToString();
System.Data.SqlClient.SqlConnection connection = new

System.Data.SqlClient.SqlConnection(EnterpriseAppl ication.Application.Connec
tionString);
asas = new DataSet();
SqlDataAdapter ad;
ad = new SqlDataAdapter("Select * from Store_Articles", connection);
ad.Fill(asas, "Table");
dvp = new DataView(asas.Tables["Table"]);

if(!(Page.IsPostBack))
{
dvp.Sort = "SortOrder";
ListBox1.DataSource = dvp;
ListBox1.DataMember = "Table";
ListBox1.DataValueField = "ArticleID";
ListBox1.DataTextField = "Name";
ListBox1.DataBind();
}
}

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent()
{
this.ListBox1.SelectedIndexChanged += new
System.EventHandler(this.ListBox1_SelectedIndexCha nged);
this.Load += new System.EventHandler(this.Page_Load);
}

private void ListBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
dvp.RowFilter = "ArticleID = '" + ListBox1.SelectedValue.ToString() +
"'";
lblArticleView.Text = dvp[0].Row["Text"].ToString();
}
}
}



Nov 15 '05 #4

P: n/a
Hi

In the document head
http://msdn.microsoft.com/library/de...jects/base.asp
--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"James Radke" <jr*****@wi.rr.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Where would you use that? In the popup page itself? Then you wouldn't need the separate .htm or .asp page?

Jim

"Vidar Petursson" <th**************************@icysoft.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Or try using
<base target="_self">

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"James Radke" <jr*****@wi.rr.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Every time you do a postback in a modal dialog it opens a new windows. I
am
not sure why that happens, but there is a way to get around it. Instead
of
calling the pop-up page, you will need to create an 'interim' .asp or

.htm page set up as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Add New Ship To</title>
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body MS_POSITIONING="FlowLayout">
<IFRAME width='100%' height='100%' NAME="Frame1"
SRC="<popuppage.aspx"> </IFRAME>
</body>
</html>

By having the popuppage in an Iframe and using the this 'interim' page

as the direct call from the javascript ShowModalDialog as follows:

var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
var result = window.showModalDialog("interimpage.html",null, WinSettings);
This will eliminate the opening of a new window when the popuppage
refreshes.

Let me know if you have any other questions!

Thanks!

Jim

"news" <me*******@yahoo.com> wrote in message
news:xT*****************@newsread3.news.atl.earthl ink.net...
> Not really sure if this is a javascript problem or C# - sorry if in
> wrong place.
>
> Modal Forms Question in Web Application
> I have two web forms: Form1 and Form2
>
> Form1 calls Form2 using showModalDialog
>
> var WinSettings = "resizable:no;dialogHeight:600px;dialogWidth:6 00"
> var result = window.showModalDialog("Form2.aspx",null, WinSettings);
>
>
> Form2 has a ListBox, a Label and a Button. The listbox is populated
> from a sql call to the database. The "SelectedIndexChanged" event
> changes the text appearing on the label to the value associated from
> the ListBox. The Button closes the form and returns the text from the > label. Form2 works properly when ran by itself.
>
> However, when I load it using showModalDialog from Form1, the first
> time the "SelectedIndexChanged" event fires, a new window opens up of > class Form2 rather than just changing the text in the Label field.
>
> Any help would be appreciated.
>
> -------------Form2 Code Behind-----------
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
> using EnterpriseObjects;
> using StoreObjects;
> using System.Data.SqlClient;
>
> using System.Configuration;
>
> namespace ASPNET.StarterKit.Portal
> {
> public class Form2 : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.Label lblArticleView;
> protected DataView dvp;
> protected System.Web.UI.WebControls.ListBox ListBox1;
> protected DataSet asas;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> EnterpriseApplication.Application.ConnectionString =
> ConfigurationSettings.AppSettings["ConnectionString"].ToString();
> System.Data.SqlClient.SqlConnection connection = new
>

System.Data.SqlClient.SqlConnection(EnterpriseAppl ication.Application.Connec
> tionString);
> asas = new DataSet();
> SqlDataAdapter ad;
> ad = new SqlDataAdapter("Select * from Store_Articles", connection);
> ad.Fill(asas, "Table");
> dvp = new DataView(asas.Tables["Table"]);
>
> if(!(Page.IsPostBack))
> {
> dvp.Sort = "SortOrder";
> ListBox1.DataSource = dvp;
> ListBox1.DataMember = "Table";
> ListBox1.DataValueField = "ArticleID";
> ListBox1.DataTextField = "Name";
> ListBox1.DataBind();
> }
> }
>
> override protected void OnInit(EventArgs e)
> {
> InitializeComponent();
> base.OnInit(e);
> }
>
> private void InitializeComponent()
> {
> this.ListBox1.SelectedIndexChanged += new
> System.EventHandler(this.ListBox1_SelectedIndexCha nged);
> this.Load += new System.EventHandler(this.Page_Load);
> }
>
> private void ListBox1_SelectedIndexChanged(object sender,
> System.EventArgs e)
> {
> dvp.RowFilter = "ArticleID = '" + ListBox1.SelectedValue.ToString() + > "'";
> lblArticleView.Text = dvp[0].Row["Text"].ToString();
> }
> }
> }
>
>



Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.