PC Review


Reply
Thread Tools Rating: Thread Rating: 3 votes, 1.00 average.

ASP.NET 2.0 Modal Dialog Window & Master Page

 
 
ABHIJIT B
Guest
Posts: n/a
 
      24th Jan 2008

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',window);
" +
"
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").FindControl("lblHeader").UniqueID];
lblMasterHeader.Text = "DataChecker - Manage Users";




 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      24th Jan 2008
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',window);
> " +
> "
> 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").FindControl("lblHeader").UniqueID];
> lblMasterHeader.Text = "DataChecker - Manage Users";
>
>
>
>
>

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      24th Jan 2008
"bruce barker" <(E-Mail Removed)> wrote in message
news:0A7FA7D0-195D-4AA8-9AEE-(E-Mail Removed)...

> 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

 
Reply With Quote
 
ABHIJIT B
Guest
Posts: n/a
 
      30th Jan 2008
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*am, bruce barker
<brucebar...@discussions.microsoft.com> wrote:
> 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 usesa
> 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="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',window);
> > " +
> > * * * * * * * * * * * * "
> > 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").FindControl("lblHeader*").UniqueID];
> > lblMasterHeader.Text = "DataChecker - Manage Users";- Hide quoted text-

>
> - Show quoted text -


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      30th Jan 2008
"ABHIJIT B" <(E-Mail Removed)> wrote in message
news:84886972-1afc-4e20-95cc-(E-Mail Removed)...

> 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

 
Reply With Quote
 
ABHIJIT B
Guest
Posts: n/a
 
      31st Jan 2008
Thanks Mark

Can you suggest mistake I am making in below code,

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

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="DC.master.cs" Inherits="MasterPage" %>

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

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

<link href="DCStyleSheet/DCStyles.css" type="text/css"
rel="stylesheet" />
</head>
<body>
<form id="DCMaster" runat="server">

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

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

</asp:contentplaceholder>

<asp:Label ID="masterCopyrightLabel" runat="server"
CssClass="CopyrightLabelStyle"
Text="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 =
(Label)Master.FindControl("lblHeader");
lblMasterHeader.Text = "DC - Users";

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

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


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

On Jan 30, 1:00*pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "ABHIJIT B" <abhijitbavdhan...@gmail.com> wrote in message
>
> news:84886972-1afc-4e20-95cc-(E-Mail Removed)...
>
> > 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 RaeASP.NETMVPhttp://www.markrae.net


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      31st Jan 2008
"ABHIJIT B" <(E-Mail Removed)> wrote in message
news:c5788987-0ba3-4f10-880c-(E-Mail Removed)...
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

 
Reply With Quote
 
ABHIJIT B
Guest
Posts: n/a
 
      31st Jan 2008
Hi Mark,

Thanks Mark for helping me out.
Take Care

Abhijit B

On Jan 31, 1:55*pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "ABHIJIT B" <abhijitbavdhan...@gmail.com> wrote in message
>
> news:c5788987-0ba3-4f10-880c-(E-Mail Removed)...
> 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 MVPhttp://www.markrae.net


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refreshing parent page from a child page opened as a modal dialog boxOptions Bali Microsoft ASP .NET 0 31st Oct 2008 09:57 PM
ASP.NET 2.0 Modal Dialog Window ABHIJIT B Microsoft ASP .NET 0 18th Feb 2008 10:22 PM
How to display a modal dialog box on top of an email msg window in =?Utf-8?B?SW5iYXI=?= Microsoft Outlook VBA Programming 4 2nd Dec 2004 03:02 AM
Why can't I execute Javascript in a modal dialog window? jm Microsoft ASP .NET 2 19th Jan 2004 01:10 AM
modal dialog window problem Garey Mills Microsoft Windows 2000 Security 0 5th Dec 2003 06:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:22 AM.