S
Seguros Catatumbo
Hi, i have decent experience with asp 3.0 (classic), and downloaded web
developer express to see what's the fuzz over it. I have lots of
questions, mostly regarding the use of forms and database use.
1) Why should i use the asp:label, asp:textbox, asp:submit instead of
plain old html input type="...", form action="..."
2) What's up with all those javascript:__dopostback links when using
some controls? Does it mean text browsers and such couldn't use the
site?
3) Code-behind files. Can i use code-behind files when posting to the
same page? I have some pages on asp 3.0 that are like this:
example.asp
<%if request.form="" then%>
Enter your login and password (show input and submit, post to the same
page)
<%else%>
<connect to database, if successfull show links or other stuff, else
redirect to error page
<%end if
I wouldn't know how to use code behind files for that behaviour, since
i wouldn't know how to insert the "if not ispostback.. then... end if"
code and printing the bunch of labels...
My guess is that i should only use code behind files if posting to a
different page.
4) How to do database queries programatically?
In asp 3, i had this code:
set conn= server.createobject("adodb.connection")
conn.open application("connectionstring")
sql="select * from something"
set rs=conn.execute(sql)
if not rs.eof then
<table>
do while not rs.eof
<tr><td><%=rs(0)%></td></tr>
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
in asp.net, i have ported that code to this:
Dim dbconn = New
SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
dbconn.open()
Dim sql = "select * from something"
Dim dbcomm = New SqlCommand(sql, dbconn)
Dim dbread = dbcomm.executeReader()
customers.DataSource = dbread
customers.DataBind()
%>
<asp:Repeater id="customers" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>id</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("id")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<%dbread.Close()
dbconn.Close()
I need way too more code in asp net to do what i do in asp classic. For
the record, i have used the new controls that you just drag and drop
and you just modify the sql and parameters. Am i using the proper way
to do this in aspnet programatically?
5) If i migrate to asp net, i would like to have almost all code in the
code behind files, and use the aspx files mainly as templates. The code
in 4) is far from this. Is there a way to do this cleanly ? I can't see
myself loosing my ties with the old form of development, it may be
messy but it is very flexible.
6) THe new login controls. How do they work by default? I have a
"dummies" book and it says that it creates a database by default for
the users. I went to the asp configuration pages and created some
users, but don't see where those users are getting stored. The book
says i can implement a membership provider by implementing a class. I
guess that is powerful but a little cumbersome comparing to having a
username and password being asked, reading the values, doing a query
with them and reacting for the result.
All right, i can't think of anything else for now. Thanks in advance
developer express to see what's the fuzz over it. I have lots of
questions, mostly regarding the use of forms and database use.
1) Why should i use the asp:label, asp:textbox, asp:submit instead of
plain old html input type="...", form action="..."
2) What's up with all those javascript:__dopostback links when using
some controls? Does it mean text browsers and such couldn't use the
site?
3) Code-behind files. Can i use code-behind files when posting to the
same page? I have some pages on asp 3.0 that are like this:
example.asp
<%if request.form="" then%>
Enter your login and password (show input and submit, post to the same
page)
<%else%>
<connect to database, if successfull show links or other stuff, else
redirect to error page
<%end if
I wouldn't know how to use code behind files for that behaviour, since
i wouldn't know how to insert the "if not ispostback.. then... end if"
code and printing the bunch of labels...
My guess is that i should only use code behind files if posting to a
different page.
4) How to do database queries programatically?
In asp 3, i had this code:
set conn= server.createobject("adodb.connection")
conn.open application("connectionstring")
sql="select * from something"
set rs=conn.execute(sql)
if not rs.eof then
<table>
do while not rs.eof
<tr><td><%=rs(0)%></td></tr>
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
in asp.net, i have ported that code to this:
Dim dbconn = New
SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
dbconn.open()
Dim sql = "select * from something"
Dim dbcomm = New SqlCommand(sql, dbconn)
Dim dbread = dbcomm.executeReader()
customers.DataSource = dbread
customers.DataBind()
%>
<asp:Repeater id="customers" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>id</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#Container.DataItem("id")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<%dbread.Close()
dbconn.Close()
I need way too more code in asp net to do what i do in asp classic. For
the record, i have used the new controls that you just drag and drop
and you just modify the sql and parameters. Am i using the proper way
to do this in aspnet programatically?
5) If i migrate to asp net, i would like to have almost all code in the
code behind files, and use the aspx files mainly as templates. The code
in 4) is far from this. Is there a way to do this cleanly ? I can't see
myself loosing my ties with the old form of development, it may be
messy but it is very flexible.
6) THe new login controls. How do they work by default? I have a
"dummies" book and it says that it creates a database by default for
the users. I went to the asp configuration pages and created some
users, but don't see where those users are getting stored. The book
says i can implement a membership provider by implementing a class. I
guess that is powerful but a little cumbersome comparing to having a
username and password being asked, reading the values, doing a query
with them and reacting for the result.
All right, i can't think of anything else for now. Thanks in advance