Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2004, 05:31 AM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to knagendrak
Default Frames in ASP.NET

Hi All!

I am new to the DOT NET.

I am doing a small project in ASP.NET

I have a small problem

Scenario:

I have two frames in my WebForm.
In the first frame i have "Department" which user has to select.
As soon as user selects corresponding Department Employees should be displayed in the Second Frame as soon as user clicks the button in First Frame.

Can anybody help me in this regards

Thanks in advance

Nag
 
Old August 3rd, 2004, 06:08 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to use javascript to point the other frame. You'll need to generate a hyperlink for each department using whatever method is appropriate for the way you generate the list. Then make the link target the other frame with a querystring value of the department ID.
 
Old August 17th, 2004, 10:44 AM
Authorized User
 
Join Date: Jul 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello
    Your first frame should have an asp:DropDownList control with the onSelectedIndexChanged="someProcedure" and autopostback property set to true. Then put some code in the "someprocedure" to put the selectedItem.value or selectedItem.text to the criterior then navigate to the secon frame.The code should look like this.
Private Sub SomeProcedure()
Response.Redirect("yourResultPage.aspx?Department= '" & YourDropDownList.SelectedItem.Text & "' Target='yourSecondFrame_Id'")
end sub
But you will face some bug of the onselectedIndexCHanged if someone choose the first item nothing will happen.
Because the first time the page load the first item will be chose by default then no index change.The event will not fired.You can set the autopostback to false.Put a submit button then put the samecode inside the onCLick event of this button instead. doctorsom from Thailand


 
Old August 18th, 2004, 05:02 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

There are other ways without using javascript(& frames)
i.e you could have two repeaters one includes Department another shows details(according another column in ur datasource) then you can Bind second repeater everytime u need according to the first one.
HTH.

--------------------------------------------
Mehdi.:)
 
Old August 18th, 2004, 05:51 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Have a look at this example
Code:
<%@ Import Namespace="System.Data.SqlClient" %>

<Script Runat="Server">

Sub Page_Load
  If Not IsPostBack
    BindDataList
  End If
End Sub

Sub BindDataList
  Dim conNorthwind As SqlConnection
  Dim cmdSelect As SqlCommand
  Dim dtrCategories As SqlDataReader

  conNorthwind = New SqlConnection( "Server=localhost;UID=sa;PWD=secret;Database=Northwind" )
  cmdSelect = New SqlCommand( "Select CategoryID, CategoryName From Categories", conNorthwind )
  conNorthwind.Open()
  dtrCategories = cmdSelect.ExecuteReader()

  dlstCategories.DataSource = dtrCategories
  dlstCategories.DataBind()

  dtrCategories.Close()
  conNorthwind.Close()
End Sub

Sub BindRepeater( intCatID As Integer )
  Dim conNorthwind As SqlConnection
  Dim strSelect As String
  Dim cmdSelect As SqlCommand
  Dim dtrProducts As SqlDataReader

  conNorthwind = New SqlConnection( "Server=localhost;UID=sa;PWD=secret;Database=Northwind" )
  strSelect = "Select ProductName From Products Where CategoryID=@catID"
  cmdSelect = New SqlCommand( strSelect, conNorthwind )
  cmdSelect.Parameters.Add( "@catID", intCatID )
  conNorthwind.Open()
  dtrProducts = cmdSelect.ExecuteReader()

  rptProducts.DataSource = dtrProducts
  rptProducts.DataBind()

  dtrProducts.Close()
  conNorthwind.Close()
End Sub

Sub dlstCategories_ItemCommand( s As Object, e As DataListCommandEventArgs )
  Dim intCatID As Integer

  dlstCategories.SelectedIndex = e.Item.ItemIndex
  BindDataList
  intCatID = dlstCategories.DataKeys( e.Item.ItemIndex )
  BindRepeater( intCatID )
End Sub

</Script>

<html>
<head><title>DataListMasterDetail.aspx</title></head>
<body>
<form Runat="Server">

<table width="100%">
<tr><td valign="top">

<asp:DataList
  ID="dlstCategories"
  OnItemCommand="dlstCategories_ItemCommand"
  DataKeyField="CategoryID"
  ItemStyle-BorderStyle="Solid"
  ItemStyle-BorderColor="Blue"
  Width="200"
  CellPadding="5"
  CellSpacing="10"
  BackColor="lightgrey"
  Runat="Server">

<ItemTemplate>
  <asp:LinkButton
    Text='<%# Container.DataItem( "CategoryName" )%>'
    Runat="Server" />
</ItemTemplate>

<SelectedItemTemplate>
  <b><i><%# Container.DataItem( "CategoryName" )%></i></b>
</SelectedItemTemplate>

</asp:DataList>

</td><td valign="top" width="100%">

<asp:Repeater
  ID="rptProducts"
  Runat="Server">

<ItemTemplate>
  <%# Container.DataItem( "ProductName" ) %>
</ItemTemplate>

<SeparatorTemplate>

</SeparatorTemplate>

</asp:Repeater>

</td></tr>
</table>

</form>
</body>
</html>
--------------------------------------------
Mehdi.:)
 
Old September 23rd, 2004, 10:57 PM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Frames!!! They are evil!
Passing data between frames is a major pain. Frames use different processes on the browser which results
in different session IDs. This means that you can use the Session state bag...
Try it and see for yourself and then drop the frame idea..

 
Old September 24th, 2004, 12:42 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I agree with you that frames are a pain to work with and usually can be avoided.

However, I don't agree with the Session ID being different for each frame. Try this and see for yourself:
Code:
frameset.asp
<frameset rows="80,*,80" frameborder="NO" border="0" framespacing="0">
  <frame src="1.asp" name="topFrame" scrolling="NO" noresize>
  <frame src="2.asp" name="mainFrame">
</frameset>

1.asp and 2.asp
<body>
<%
    Response.Write("Session ID " & Session.SessionID)
%>
</body>
When you run this, you'll see that both frames have the same Session ID.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 24th, 2004, 08:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

My issue with cross-frame scripting is MSFT keeps changing the rules... It's so much easier not to use frames and find a more elegant solution

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee





Similar Threads
Thread Thread Starter Forum Replies Last Post
Turning a regular ASP.NET App into an AJAX ASP.Net donrafeal7 Ajax 2 August 31st, 2007 12:33 AM
display without frames in asp mahalakshmik Classic ASP Databases 1 October 6th, 2006 07:10 AM
asp.net frames and gridview ramuis78 ASP.NET 1.0 and 1.1 Basics 2 August 2nd, 2006 10:04 AM
I need help with Frames and Forms in ASP.NET leex Classic ASP Basics 1 August 19th, 2004 11:44 PM
Frames in ASP??? benskywalker Classic ASP Basics 8 September 29th, 2003 01:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.