5 Replies - 4564 Views - Last Post: 16 January 2009 - 04:43 AM Rate Topic: -----

#1 raghavendra  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 11-August 08

asp.net master pages to an existing website

Post icon  Posted 10 January 2009 - 04:38 AM

Hi all,

i am new to master page programmingin asp.net 2.0. I did not know that before creating my website i needed to create a master page but now i have created 3 webpages with all the controls like a form for entering details of a employee. All the 3 pages i did not select the master page while creating those pages but now i have added a master page to my website. My doubt is how to add a master page to an existing website?

Any suggestions or help is greatly appreciated..

Thanks in advance,
Raghu.

Is This A Good Question/Topic? 0
  • +

Replies To: asp.net master pages to an existing website

#2 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: asp.net master pages to an existing website

Posted 13 January 2009 - 06:38 AM

  • Add a master page to your project.
  • Format the master page the way you want the site to look
  • Place a ContentPlaceHolder control where you want the content to appear in the underlying pages. This is normally in the center part of the page.
  • Recreate the pages you need this time selecting the master page IMPORTANT: DO NOT DELETE THE OTHER PAGES YET!
  • Select the markup from the old pages between the form tags and paste it into the new page between the content place holder location.
  • Select the code behind code and paste it into the new code behind of the new page.


hope this helps
Was This Post Helpful? 1
  • +
  • -

#3 raghavendra  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 11-August 08

Re: asp.net master pages to an existing website

Posted 15 January 2009 - 06:38 AM

View Postdklingman, on 13 Jan, 2009 - 05:38 AM, said:

  • Add a master page to your project.
  • Format the master page the way you want the site to look
  • Place a ContentPlaceHolder control where you want the content to appear in the underlying pages. This is normally in the center part of the page.
  • Recreate the pages you need this time selecting the master page IMPORTANT: DO NOT DELETE THE OTHER PAGES YET!
  • Select the markup from the old pages between the form tags and paste it into the new page between the content place holder location.
  • Select the code behind code and paste it into the new code behind of the new page.


hope this helps


Hi dklingman,

Gr8 work. Thank you very much ur answer has helped me alot i did the way u have suggested and it works....

Thank u once again.

I have another problem regarding retrieving the values from sql database according to the value of the name in the database.

I did some coding but i am not able to get the desired results.

My code is here:

 
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim DBAdap As New Data.SqlClient.SqlDataAdapter
		Dim DS As New Data.DataSet
		DBConn.Open()
		'Dim DBCmd As New Data.SqlClient.SqlCommand("Select Designation,ContactNumber,EmergencyContact,OfficeNumber,Email,PersonalEmail,Dob,Doj,Address,BankName,Branch,AccountNumber,Salary from Employeedata Where Id =  1", DBConn)
		Dim DBCmd As New Data.SqlClient.SqlCommand("Select * from Employeedata where ID=5", DBConn)
		dataReader = DBCmd.ExecuteReader()
		If (dataReader.Read()) Then
			ddlid.SelectedValue = dataReader("ID").ToString()
			ddlname.SelectedValue = dataReader("EName").ToString()
			txtdept.Text = dataReader("Department").ToString()
			txtdesig.Text = dataReader("Designation").ToString()
			txtcnum.Text = dataReader("ContactNumber").ToString()
			txtemercont.Text = dataReader("EmergencyContact").ToString()
			txtofficenum.Text = dataReader("OfficeNumber").ToString()
			txtemailid.Text = dataReader("Email").ToString()
			txtpid.Text = dataReader("PersonalEmail").ToString()
			txt_dob.Text = dataReader("Dob").ToString()
			txtdoj.Text = dataReader("Doj").ToString()
			txtaddress.Text = dataReader("Address").ToString()
			txtbgrp.Text = dataReader("BloodGroup").ToString()
			txtbankname.Text = dataReader("BankName").ToString()
			txtbranch.Text = dataReader("Branch").ToString()
			txtaccountnum.Text = dataReader("AccountNumber").ToString()
			ddldetid.SelectedValue = dataReader("Details_of_Id_Card").ToString()
			txtsal.Text = dataReader("Salary").ToString()
		End If
		DBConn.Close()
		dataReader.Close()
End Class



My problem is i have a drop down for Name in my form and the remaining fields are related to the particular name but i have to change the values according to the name that i have selected.

How can we do that?
Thanks in advance,
Raghu.
Was This Post Helpful? 0
  • +
  • -

#4 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: asp.net master pages to an existing website

Posted 15 January 2009 - 06:45 AM

i'm trying to understand what you're asking here. are you saying when you select a different value from the drop down that you what the other values to change that are displayed based on the value that you selected?
Was This Post Helpful? 0
  • +
  • -

#5 raghavendra  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 11-August 08

Re: asp.net master pages to an existing website

Posted 16 January 2009 - 04:14 AM

View Postdklingman, on 15 Jan, 2009 - 05:45 AM, said:

i'm trying to understand what you're asking here. are you saying when you select a different value from the drop down that you what the other values to change that are displayed based on the value that you selected?


Thanks for ur Reply DkLingman,

No actually i have a drop down list for Label ID and it is a databound control with values from the backend will be displayed in the drop down list.
There are other controls like Name, Department, Designation, Contact Number and such controls pertaining to a particular Id. In my Select Statement i am able to mention only one value like
Select * from Employeedata where Id=1
like that i wanted to display the details (Name, Dept,Desig, Contact Number Etc) for other ids just by selecting the id value from the Drop Down list.

Thanks in advance,
Raghu.
Was This Post Helpful? 0
  • +
  • -

#6 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: asp.net master pages to an existing website

Posted 16 January 2009 - 04:43 AM

you need to replace the 1 with the selected value from your drop down list by appending the value to your select statement.

"Select * from Employeedata where Id=" + Your_DropDownList.SelectedValue


This post has been edited by dklingman: 16 January 2009 - 04:44 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1