Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / January 2008

Tip: Looking for answers? Try searching our database.

ASP.NET 2.0 Modal Dialog Window & Master Page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ABHIJIT B - 24 Jan 2008 16:15 GMT
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";
bruce barker - 24 Jan 2008 16:49 GMT
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)

> Kindly help me in following
>
[quoted text clipped - 106 lines]
> Request.Form[this.FindControl("ContentPlaceHolder1").FindControl("lblHeader").UniqueID];
> lblMasterHeader.Text = "DataChecker - Manage Users";
Mark Rae [MVP] - 24 Jan 2008 17:24 GMT
> 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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

ABHIJIT B - 30 Jan 2008 17:10 GMT
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:
>
[quoted text clipped - 118 lines]
>
> - Show quoted text -
Mark Rae [MVP] - 30 Jan 2008 18:00 GMT
> 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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

ABHIJIT B - 31 Jan 2008 17:26 GMT
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";

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

> > Can you let me know how can I change Label
> > text of Master page in Content page
[quoted text clipped - 11 lines]
> --
> Mark RaeASP.NETMVPhttp://www.markrae.net
Mark Rae [MVP] - 31 Jan 2008 18:55 GMT
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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

ABHIJIT B - 31 Jan 2008 20:02 GMT
Hi Mark,

Thanks Mark for helping me out.
Take Care

Abhijit B

> Thanks Mark
>
[quoted text clipped - 16 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.