ASP.NET 2.0 Modal Dialog Window & Master Page

Kindly help me in following

1.In my module, I am using two pages Parent(ManageUser) and Child()
page.

Parent window has textbox and button to open Child window
Child page opens as dialog window as you click on button in Parent
page using JavaScript showwmodaldialog().
Child window has textbox and button to return value back to parent
page.

I am new to ASP.NET 2.0.I tried doing following,

Aftrer entering any value in textbox of Child page and clicking Close
button value can be seen in Parent page textbox.

-----< I am doing this changes in CodeBehind files > -----

Now, I am trying to use Hidden Control using normal HTML

<input id="hdvRowID" type="hidden" runat="server" name ="hdvRowID"/>

hdvRowID.Value = "AB";

I am not able to access value in JavaScript code so it is giving error
while
taking value.

Books.book_id = document.getElementById('hdvRowID').value;

------------------------------------------------------------ ------------------------------------------------------------ ---

< Parent page code : >

if (!ClientScript.IsStartupScriptRegistered("ManageUser"))
{

ClientScript.RegisterStartupScript(this.GetType(), "ManageUser",
" <script language=javascript> " +
" function AddBook() {" +
" var returnVal = ''; " +
" returnVal =
window.showModalDialog('SearchUsers.htm', null,'status:no;dialogWidth:
500px; dialogHeight:500px;dialogHide:true;center:yes;help:no',windo w);
" +
"
document.getElementById('txtSLoginName').value = returnVal.book_id;
document.getElementById('txtSFirstName').value = returnVal.book_name;
" +
" return false; }" +
" </script>");
}
------------------------------------------------------------ ------------------------------------------------------------ ---
< Child page code : >

ClientScript.RegisterHiddenField("txthidLoginID1", "XYZ");

btnSUOK1.Attributes.Add("onclick", "return
ReturnBook()");

if (!
ClientScript.IsStartupScriptRegistered("SearchUsers"))
{
ClientScript.RegisterStartupScript(this.GetType(),
"SearchUsers",
" <script language=javascript> " +
" function Books() { " +
" var book_id = ''; var book_name = ''; }" +
" function ReturnBook() {" +
" var Books = new Object(); " +
" Books.book_id =
document.getElementById('textboxBookID').value; " +
" Books.book_name =
document.getElementById('textboxBookName').value; " +
" window.returnValue = Books; window.close(); }" +
//" return false; }" +
" </script>");
}

2. In our application we are using only one Master page having label
control

All pages uses Master page

<label id="lblHeader" class="ApplicationLabelStyle" style="font-
weight:normal" >DataChecker</label>

<asp:contentplaceholder id="ContentPlaceHolder1"
runat="server">
</asp:contentplaceholder>

I am trying to change Master page label lblHeader text to Manage User
using following code,I am getting error.

A.

Label lblMasterHeader = (Label)Master.FindControl("lblHeader");
lblMasterHeader.Text = "DataChecker - Manage Users";

B.

Label lblMasterHeader =
(Label)Master.FindControl("ContentPlaceHolder1").FindControl ("lblHeader");
lblMasterHeader.Text = "DataChecker - Manage Users";

C.

string selectedValue =
Request.Form[this.FindControl("ContentPlaceHolder1").FindCon trol("lblHeader").UniqueID];
lblMasterHeader.Text = "DataChecker - Manage Users";
ABHIJIT B [ Do, 24 Januar 2008 17:15 ] [ ID #1915168 ]

RE: ASP.NET 2.0 Modal Dialog Window & Master Page

try:

Books.book_id = document.getElementById('<%=hdvRowID.ClientID%>').value;

also you should move away from a modaldialog solution. this is an IE only
feature and may be droped as IE becomes more w3c compliant. most site uses a
floating div to do this feature. the ajaxtoolkit also has a solution.


-- bruce (sqlwork.com)


"ABHIJIT B" wrote:

>
> Kindly help me in following
>
> 1.In my module, I am using two pages Parent(ManageUser) and Child()
> page.
>
> Parent window has textbox and button to open Child window
> Child page opens as dialog window as you click on button in Parent
> page using JavaScript showwmodaldialog().
> Child window has textbox and button to return value back to parent
> page.
>
> I am new to ASP.NET 2.0.I tried doing following,
>
> Aftrer entering any value in textbox of Child page and clicking Close
> button value can be seen in Parent page textbox.
>
> -----< I am doing this changes in CodeBehind files > -----
>
> Now, I am trying to use Hidden Control using normal HTML
>
> <input id="hdvRowID" type="hidden" runat="server" name ="hdvRowID"/>
>
> hdvRowID.Value = "AB";
>
> I am not able to access value in JavaScript code so it is giving error
> while
> taking value.
>
> Books.book_id = document.getElementById('hdvRowID').value;
>
> ------------------------------------------------------------ ------------------------------------------------------------ ---
>
> < Parent page code : >
>
> if (!ClientScript.IsStartupScriptRegistered("ManageUser"))
> {
>
> ClientScript.RegisterStartupScript(this.GetType(), "ManageUser",
> " <script language=javascript> " +
> " function AddBook() {" +
> " var returnVal = ''; " +
> " returnVal =
> window.showModalDialog('SearchUsers.htm', null,'status:no;dialogWidth:
> 500px; dialogHeight:500px;dialogHide:true;center:yes;help:no',windo w);
> " +
> "
> document.getElementById('txtSLoginName').value = returnVal.book_id;
> document.getElementById('txtSFirstName').value = returnVal.book_name;
> " +
> " return false; }" +
> " </script>");
> }
> ------------------------------------------------------------ ------------------------------------------------------------ ---
> < Child page code : >
>
> ClientScript.RegisterHiddenField("txthidLoginID1", "XYZ");
>
> btnSUOK1.Attributes.Add("onclick", "return
> ReturnBook()");
>
> if (!
> ClientScript.IsStartupScriptRegistered("SearchUsers"))
> {
> ClientScript.RegisterStartupScript(this.GetType(),
> "SearchUsers",
> " <script language=javascript> " +
> " function Books() { " +
> " var book_id = ''; var book_name = ''; }" +
> " function ReturnBook() {" +
> " var Books = new Object(); " +
> " Books.book_id =
> document.getElementById('textboxBookID').value; " +
> " Books.book_name =
> document.getElementById('textboxBookName').value; " +
> " window.returnValue = Books; window.close(); }" +
> //" return false; }" +
> " </script>");
> }
>
> 2. In our application we are using only one Master page having label
> control
>
> All pages uses Master page
>
> <label id="lblHeader" class="ApplicationLabelStyle" style="font-
> weight:normal" >DataChecker</label>
>
> <asp:contentplaceholder id="ContentPlaceHolder1"
> runat="server">
> </asp:contentplaceholder>
>
> I am trying to change Master page label lblHeader text to Manage User
> using following code,I am getting error.
>
> A.
>
> Label lblMasterHeader = (Label)Master.FindControl("lblHeader");
> lblMasterHeader.Text = "DataChecker - Manage Users";
>
> B.
>
> Label lblMasterHeader =
> (Label)Master.FindControl("ContentPlaceHolder1").FindControl ("lblHeader");
> lblMasterHeader.Text = "DataChecker - Manage Users";
>
> C.
>
> string selectedValue =
> Request.Form[this.FindControl("ContentPlaceHolder1").FindCon trol("lblHeader").UniqueID];
> lblMasterHeader.Text = "DataChecker - Manage Users";
>
>
>
>
>
brucebarker [ Do, 24 Januar 2008 17:49 ] [ ID #1915184 ]

Re: ASP.NET 2.0 Modal Dialog Window & Master Page

"bruce barker" <brucebarker [at] discussions.microsoft.com> wrote in message
news:0A7FA7D0-195D-4AA8-9AEE-234D8E087379 [at] microsoft.com...

> also you should move away from a modaldialog solution.

Definitely.

> this is an IE only feature

IE and, curiously, Safari for Mac... :-)

> and may be droped as IE becomes more w3c compliant. most site uses a
> floating div to do this feature. the ajaxtoolkit also has a solution.

Yes indeed - extremely simple to set up...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
mark [ Do, 24 Januar 2008 18:24 ] [ ID #1915194 ]

Re: ASP.NET 2.0 Modal Dialog Window & Master Page

Thanks Bruce.

This is client requirement.Can you let me know How can I change Label
text of Master page in Content page

Thanks in advance.

On Jan 24, 11:49=A0am, bruce barker
<brucebar... [at] discussions.microsoft.com> wrote:
> try:
>
> Books.book_id =3D document.getElementById('<%=3DhdvRowID.ClientID%>').valu=
e;
>
> also you should move away from a modaldialog solution. this is an IE only
> feature and may be droped as IE becomes more w3c compliant. most site uses=
a
> floating div to do this feature. the ajaxtoolkit also has a solution.
>
> -- bruce (sqlwork.com)
>
>
>
> "ABHIJIT B" wrote:
>
> > Kindly help me in following
>
> > 1.In my module, I am using two pages Parent(ManageUser) and Child()
> > page.
>
> > Parentwindowhas textbox and button to open Childwindow
> > Child page opens asdialogwindowas you click on button in Parent
> > page using JavaScript showwmodaldialog().
> > Childwindowhas textbox and button to return value back to parent
> > page.
>
> > I am new to ASP.NET 2.0.I tried doing following,
>
> > Aftrer entering any value in textbox of Child page and clicking Close
> > button value can be seen in Parent page textbox.
>
> > -----< I am doing this changes in CodeBehind files > -----
>
> > Now, I am trying to use Hidden Control using normal HTML
>
> > <input id=3D"hdvRowID" type=3D"hidden" runat=3D"server" name =3D"hdvRowI=
D"/>
>
> > hdvRowID.Value =3D "AB";
>
> > I am not able to access value in JavaScript code so it is giving error
> > while
> > taking value.
>
> > Books.book_id =3D document.getElementById('hdvRowID').value;
>
> > ------------------------------------------------------------ ------------=
---=AD------------------------------------------------
>
> > < Parent page code : >
>
> > if (!ClientScript.IsStartupScriptRegistered("ManageUser"))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
>
> > ClientScript.RegisterStartupScript(this.GetType(), "ManageUser",
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " <script language=3Djav=
ascript> " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " function AddBook() {" =
+
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " =A0var returnVal =3D '=
'; " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " =A0returnVal =3D
> >window.showModalDialog('SearchUsers.htm', null,'status:no;dialogWidth:
> > 500px; dialogHeight:500px;dialogHide:true;center:yes;help:no',windo w);
> > " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "
> > document.getElementById('txtSLoginName').value =3D returnVal.book_id;
> > document.getElementById('txtSFirstName').value =3D returnVal.book_name;
> > " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " return false; }" +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " </script>");
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> > ------------------------------------------------------------ ------------=
---=AD------------------------------------------------
> > < Child page code : >
>
> > ClientScript.RegisterHiddenField("txthidLoginID1", "XYZ");
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 btnSUOK1.Attributes.Add("onclick", "retu=
rn
> > ReturnBook()");
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!
> > ClientScript.IsStartupScriptRegistered("SearchUsers"))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ClientScript.RegisterStartupScri=
pt(this.GetType(),
> > "SearchUsers",
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " <script language=3Djavascript>=
" +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " function Books() =A0{ " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " var book_id =3D ''; var book_n=
ame =3D ''; }" +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " function ReturnBook() {" +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " var Books =3D new Object(); " =
+
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " Books.book_id =3D
> > document.getElementById('textboxBookID').value; " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " Books.book_name =3D
> > document.getElementById('textboxBookName').value; " +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "window.returnValue =3D Books;wi=
ndow.close(); }" +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //" return false; }" +
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 " </script>");
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> > 2. In our application we are using only one Master page having label
> > control
>
> > All pages uses Master page
>
> > <label id=3D"lblHeader" class=3D"ApplicationLabelStyle" style=3D"font-
> > weight:normal" >DataChecker</label>
>
> > <asp:contentplaceholder id=3D"ContentPlaceHolder1"
> > runat=3D"server">
> > </asp:contentplaceholder>
>
> > I am trying to change Master page label lblHeader text to Manage User
> > using following code,I am getting error.
>
> > A.
>
> > Label lblMasterHeader =3D (Label)Master.FindControl("lblHeader");
> > lblMasterHeader.Text =3D "DataChecker - Manage Users";
>
> > B.
>
> > Label lblMasterHeader =3D
> > (Label)Master.FindControl("ContentPlaceHolder1").FindControl ("lblHeader"=
);
> > lblMasterHeader.Text =3D "DataChecker - Manage Users";
>
> > C.
>
> > string selectedValue =3D
> > Request.Form[this.FindControl("ContentPlaceHolder1").FindCon trol("lblHea=
der=AD").UniqueID];
> > lblMasterHeader.Text =3D "DataChecker - Manage Users";- Hide quoted text=
-
>
> - Show quoted text -
ABHIJIT B [ Mi, 30 Januar 2008 18:10 ] [ ID #1919946 ]

Re: ASP.NET 2.0 Modal Dialog Window & Master Page

"ABHIJIT B" <abhijitbavdhankar [at] gmail.com> wrote in message
news:84886972-1afc-4e20-95cc-3899c6da7620 [at] f10g2000hsf.google groups.com...

> Can you let me know how can I change Label
> text of Master page in Content page

You would typically create a property on the MasterPage and set it from the
content page.

Alternatively, you might just be able to do:

((Label)Master.FindControl("MyLabel")).Text = "Hello";

depending on how your MasterPage is constructed, though I would personally
favour the property method...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
mark [ Mi, 30 Januar 2008 19:00 ] [ ID #1919956 ]

Re: ASP.NET 2.0 Modal Dialog Window & Master Page

Thanks Mark

Can you suggest mistake I am making in below code,

------------------------------------------------------------ ----------------=
------------------------------------------------------------ -
Master page code :

<% [at] Master Language=3D"C#" AutoEventWireup=3D"true"
CodeFile=3D"DC.master.cs" Inherits=3D"MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns=3D"http://www.w3.org/1999/xhtml" >
<head runat=3D"server">
<title>DC Home</title>
<link rel=3D"stylesheet" type=3D"text/css" href=3D"DCStyleSheet/DC.css" =
/
>
<link href=3D"DCStyleSheet/DCStyles.css" type=3D"text/css"
rel=3D"stylesheet" />
</head>
<body>
<form id=3D"DCMaster" runat=3D"server">

<table cellpadding=3D"0" cellspacing=3D"0" width=3D"100%" border=3D"0">
<tr>
<td style=3D"height: 67px">
<table id=3D"main_header_table" cellpadding=3D"0"
cellspacing=3D"0" height=3D"51px" width=3D"100%"
border=3D"0">
<tr>
<td class=3D"HeaderTDStyle1"><img alt=3D"DC
Site logo" src=3D"DCImages/DC.gif"/></td>
<td class=3D"HeaderTDStyle3"><label
id=3D"lblHeader" class=3D"ApplicationLabelStyle" style=3D"font-
weight:normal" >DC Application</label></td>
</tr>
</table>
</td>
</tr>
</table>

<div>
<asp:contentplaceholder id=3D"ContentPlaceHolder1" runat=3D"server">

</asp:contentplaceholder>

<asp:Label ID=3D"masterCopyrightLabel" runat=3D"server"
CssClass=3D"CopyrightLabelStyle"
Text=3D"Copyright 2000-2008 Nielsen. All Rights
Reserved"></asp:Label>
</div>
</form>
</body>
</html>
------------------------------------------------------------ ------------
Content page code :

protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
/********* Setting Label ********/

Label lblMasterHeader =3D
(Label)Master.FindControl("lblHeader");
lblMasterHeader.Text =3D "DC - Users";

//ContentPlaceHolder content;
//content =3D
(ContentPlaceHolder)Page.Master.FindControl("lblHeader");

//((Label)Master.FindControl("lblHeader")).Text =3D
"Hello";


------------------------------------------------------------ ------------

On Jan 30, 1:00=A0pm, "Mark Rae [MVP]" <m... [at] markNOSPAMrae.net> wrote:
> "ABHIJIT B" <abhijitbavdhan... [at] gmail.com> wrote in message
>
> news:84886972-1afc-4e20-95cc-3899c6da7620 [at] f10g2000hsf.google groups.com...
>
> > Can you let me know how can I change Label
> > text of Master page in Content page
>
> You would typically create a property on the MasterPage and set it from th=
e
> content page.
>
> Alternatively, you might just be able to do:
>
> ((Label)Master.FindControl("MyLabel")).Text =3D "Hello";
>
> depending on how your MasterPage is constructed, though I would personally=

> favour the property method...
>
> --
> Mark RaeASP.NETMVPhttp://www.markrae.net
ABHIJIT B [ Do, 31 Januar 2008 18:26 ] [ ID #1920746 ]

Re: ASP.NET 2.0 Modal Dialog Window & Master Page

"ABHIJIT B" <abhijitbavdhankar [at] gmail.com> wrote in message
news:c5788987-0ba3-4f10-880c-4557897d23e3 [at] m34g2000hsf.google groups.com...
Thanks Mark

> Can you suggest mistake I am making in below code,

I certainly can...

> <label id="lblHeader" class="ApplicationLabelStyle"
> style="font-weight:normal" >DC Application</label>

That's an HTMLControl, not a WebControl, so it won't run server-side. Change
it to an <asp:Label> WebControl, or add runat="server"...

> Label lblMasterHeader = (Label)Master.FindControl("lblHeader");

That will only work if you change the <label> to an <asp:Label> - otherwise
it will be an HTMLGenericControl, so the cast won't work...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
mark [ Do, 31 Januar 2008 19:55 ] [ ID #1920755 ]

Re: ASP.NET 2.0 Modal Dialog Window & Master Page

Hi Mark,

Thanks Mark for helping me out.
Take Care

Abhijit B

On Jan 31, 1:55=A0pm, "Mark Rae [MVP]" <m... [at] markNOSPAMrae.net> wrote:
> "ABHIJIT B" <abhijitbavdhan... [at] gmail.com> wrote in message
>
> news:c5788987-0ba3-4f10-880c-4557897d23e3 [at] m34g2000hsf.google groups.com...
> Thanks Mark
>
> > Can you suggest mistake I am making in below code,
>
> I certainly can...
>
> > <label id=3D"lblHeader" class=3D"ApplicationLabelStyle"
> > style=3D"font-weight:normal" >DC Application</label>
>
> That's an HTMLControl, not a WebControl, so it won't run server-side. Chan=
ge
> it to an <asp:Label> WebControl, or add runat=3D"server"...
>
> > Label lblMasterHeader =3D (Label)Master.FindControl("lblHeader");
>
> That will only work if you change the <label> to an <asp:Label> - otherwis=
e
> it will be an HTMLGenericControl, so the cast won't work...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net
ABHIJIT B [ Do, 31 Januar 2008 21:02 ] [ ID #1920762 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » ASP.NET 2.0 Modal Dialog Window & Master Page

Vorheriges Thema: problem with Rowdeleting event
Nächstes Thema: Forcing ASP.NET 1.1 isn't working