|
-
January 27th, 2009, 10:41 AM
#1
asp.net tag questions
Hi All,
1. Does <frameset> tag work in asp.net application? I had a simple 3 page application with <frame>, it seems to work only in the development server. Is it a good idea not to use <frameset> and use <iframe> instead?
2. Can i include <asp:button> etc tags in the <script>?
For example
Code:
<script language="c# " runat="server">
void myfunction(){
Response.Write("<asp:hyperlink Navigateurl='two.aspx' target='frametwo' runat='server'></asp:hyperlink>
}
is this valid?
3. Is it acceptable to include runat="server" in any html tag?
Thanks for your help.
-
January 28th, 2009, 05:01 PM
#2
Re: asp.net tag questions
1. I don't know why it wouldn't. Although I've never tried. Everyone and their mother hates frames. 
The page that contains the frameset would likely be an html file since there's no way to have a postback from it. Although you could make it an aspx page and dynamically create a frame layout based on a login.
2. No that's not valid. First, Response.Write() is evil. They should never have included that in the API. I have never come across a use for it. Don't use it. It'll only give you headaches when you experience wierd problems. Also, asp.net apps writes html not .net controls. So writing out a asp:hyperlink control just doesn't make sense. You should drag and drop a asp.net hyperlink control unto your aspx page in the form designer window. Then have a function like this (if you named the control linkMyLink)
Code:
void MyFunction()
{
linkMyLink.NavigateUrl = "two.aspx";
linkMyLink.Target = "frametwo";
}
Although, I don't know why you'd do this. You can set these properties at design time in the properties window. It would be weird if a link behaved differently based on certain criteria but you can do that.
3. Sure you can have runat="server" on your html controls. Generally you don't (anything dynamic should be a asp.net control) but doing so allows you do programmatically change attributes of the html control.
Last, asp.net has no pretty nice navigation controls. There really isn't much need for frames.
Scott
-
February 3rd, 2009, 06:22 AM
#3
Re: asp.net tag questions
Thanks Scott for the explanation.
I was using response.write as i need to create a table of cells dynamically with it's content as hyperlink. After your suggestion i did some research and found out that i can dynamically create the table by using HtmlTableRow, HtmlTableCell etc.
Code:
void Page_Load(object sender, EventArgs e){
//my code to find out what goes in the table.......
for(int i = 0; i<strDirArray.Length; i++){
HtmlTableRow tr = new HtmlTableRow();
// Create column 1
HtmlTableCell td1 = new HtmlTableCell();
// Create a label control dynamically
HtmlLink link = new HtmlLink();
link.ID = "lnk" + i.ToString();
link.Href ="pagethree.asp?volname=";
// Add control to the table cell
td1.Controls.Add(_label);
tr.cells.Add(td1);
mytable.Rows.Add(tr);
}
}
The code in the html has the body, form and table
Code:
<body>
<form id="form1" runat="server">
<table id="mytable" runat="server"></table>
</form>
Am i complicating things by using HtmlTableRow and cells.... is there a easy way to do this. As i mentioned before, i would know how many rows to display only after quering the API code which goes above the function. Also, the table cells is a hyperlink which needs to pass a value to the frametwo where it opens the page.
thanks for any suggestion
-
February 3rd, 2009, 10:41 AM
#4
Re: asp.net tag questions
I would use the asp.net table control instead of the plain html one.
Code:
<body>
<form id="form1" runat="server">
<asp:table id="mytable" runat="server"></asp:table>
</form>
The code to create the table is fairly similar. However, .net has several options you could use instead. There are 3 navigation controls. SiteMapPath, Menu, and TreeView. You can configure these at design time or use a file. The file option is nice because you can change the file and update all pages that reference it. One of these (I think SiteMapPath) requires a file.
Aside from these you could use databound controls like GridView, ListView, or Repeater. Repeater might be best of these for what you want to do.
All of these basically will generate the tables and other html for you.
What data source are you using for the links?
Scott
-
February 4th, 2009, 04:41 AM
#5
Re: asp.net tag questions
I understand the use of asp:table to table. I changed to asp:table and changed the c# code to use Table rather than HtmlTable.
I don't use any database, the values are coming from a com API. INstead of passing values from one page to another using url posting as i am using hyperlink, is there a better way to do this? Also, is it possible to pass object from one page to another?
I do appreciate your time and help.
Last edited by rachelason; February 4th, 2009 at 04:54 AM.
Reason: edit
-
February 4th, 2009, 11:49 AM
#6
Re: asp.net tag questions
Well, these controls support binding to objects in addition to a database. So you could read in all the values from you com API and stick them into your own data structure them tell the control to bind to your data structure. It's usually better to let asp.net controls generate html instead of generating your own since the built-in controls will generate html that will work on any browser.
Not sure what you mean by url posting. Do you mean query string? For example that stuff after the ? in http://www.yoursite.com/yourpage.asp...othervalue=abc. Well, I guess the forum doesn't like showing the ? in the url but I think you know what I mean.
I have no idea what you mean by passing value using hyperlinks.
Passing values using the query string or the view state are nice ways to store data. However, never store critical or sensitive since they can be hacked/intercepted/altered before being sent back to the server.
For storing critical or sensitive values you can use session variables. The only downside is these values go away after the session expires (default is 20 minutes of inactivity). As long of the pages in each frame belong to the same web app they should all be able to access your session variables.
-
February 6th, 2009, 10:55 AM
#7
Re: asp.net tag questions
I am a bit lost...Are you suggesting it's best not to use the c# Tablerow etc to build the table, instead save the result of the com api data in a datastructre and then let asp.net build the table. Can you please show me some example?
Yes i do mean query string? I was wondering if there is any better way of passing value from one page to another when a hyperlink is clicked?
I am not sure which is a good idea to use either query string or session variable. The project is not a website for general public but a part of a bigger system to display few controls and manipulate it. Also, it needs to work in Mac(safari) etc... I do realise I have lot more to research on.....
-
February 11th, 2009, 07:30 AM
#8
Re: asp.net tag questions
Do you by any chance mean using System.Data.Dataset to collect the data?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|