Modal Forms Question in Web Application

N

news

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:600"
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(EnterpriseApplication.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_SelectedIndexChanged);
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();
}
}
}
 
J

James Radke

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:600"
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 said:
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:600"
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(EnterpriseApplication.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_SelectedIndexChanged);
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();
}
}
}
 
V

Vidar Petursson

Hi

Or try using
<base target="_self">

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
James Radke said:
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:600"
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 said:
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:600"
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(EnterpriseApplication.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_SelectedIndexChanged);
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();
}
}
}
 
J

James Radke

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

Jim

Vidar Petursson said:
Hi

Or try using
<base target="_self">

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
James Radke said:
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:600"
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 said:
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:600"
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(EnterpriseApplication.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_SelectedIndexChanged);
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();
}
}
}
 
V

Vidar Petursson

Hi

In the document head
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/base.asp


--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
James Radke said:
Where would you use that? In the popup page itself? Then you wouldn't need
the separate .htm or .asp page?

Jim

Vidar Petursson said:
Hi

Or try using
<base target="_self">

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
James Radke said:
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= said:
</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:600"
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

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:600"
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(EnterpriseApplication.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_SelectedIndexChanged);
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();
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top