Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

So like everyone knows in classic ASP you can mix HTML and the VBScript. Is this not possible in .NET? I'm needing to create a table that has a header and there are rows created based on an integer. Before I would just wrte the first row (header) of the table and then loop through the int and create that many rows below. Well how can I replicate that in .NET? Would I need to create two functions let's say and call those somehow? I'm a bit lost on how much you can mix HTML and VB in .NET.

 

Thanks.

Posted
Also, can you use the DataGrid with form elements? Like if I wanted to read a table, put it into a datagrid but have some of the fields be a select box...is that possible? Or is the DataGrid just for displaying results?
Posted

Well what if I wanted to create drop downs populated from a database? All of the fields are either dropdowns or text boxes. I've been reading up on using code behind so do this, but is there an advantage to code behind for something like this? I'm in my second week of .Net, and this seems to be the last of the big issues I'm having.

 

All I want to to is be able to write out a table with n rows and have the form elements populate correctly. The data population from the table will be the next thing, but first I'd like to be able just to create the correct amout of rows with one header.

 

Thanks!

  • Moderators
Posted

With the above example I use the Code-Behind method...

You can populate an array with the data from a DB and then loop through the array to generate the <td> tags.

 

For a dropdown you can use the same method or if you need to handle events, use a DropDownList (web control) and bind the data using a Dataset.

Visit...Bassic Software
  • 2 weeks later...
Posted

You should use the .NET way (Code behind), but ASP.NET still supports the ever so familiar

<% myFunction(Butt, Boots) %>

or

<% =myValue%>

 

Difference is, if you want your functions then you have to define them and update something else on the page... The sample below should be how you would update a table with info from a database (does not show connection string, etc.)

 

So, you really DONT want to mix html and vb MOST of the time. This also helps to encapsulate your data. So if you use a code behind and these methods, you could distribut your .aspx page and a .dll --- Then your code would be protected.

 

ie:

 

<script language="vb" runat="server">

Dim ds As New DataSet

Dim dg As Datagrid

dg.DataSource = ds

dg.DataBind()

</script>

 

 

<html>

 

<asp:dg runat="server">

 

</html>

Posted

It seem to be more complicated compare with classic ASP...

 

In ASP.NET, we can either use code-behind or classic ASP method to program our ASP.NET application. Did anyone test the speed?

For this example of 'bang head here', use code-behind is faster or non-code-behind?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...