tab sequence/highlighting/formatting

P

pallabs

I'm new to asp.net and is having problems doing the following:

1. The tab sequence in a asp form is not working properly. The page is
a login form and tabindex is set to 0 for username, 1 for passwd and 2
for the submit button but after tabbing from username, the focus jumps
back to the url address bar.

2. I'm trying to format strings displayed through response.write, e.g.
how to make the string bold or centered in page, or make the color
green etc. As a workaround I'm using label controls.

3. May be this is related to the above question. I'm writing the
contents of an array into a multiline textbox, row by row, and
depending on a condition, I want to highlight that row, e.g. if name =
"Michael", highlight, else just write it in the textbox. how to
highlight?

I would really appreciate if someone helps.

thanks
 
T

Tom.PesterDELETETHISSS

1. The tab sequence in a asp form is not working properly. The page is
a login form and tabindex is set to 0 for username, 1 for passwd and 2
for the submit button but after tabbing from username, the focus jumps
back to the url address bar.

Can you post your code so we can try it? Your tabindices look right and ought
to work.
2. I'm trying to format strings displayed through response.write, e.g.
how to make the string bold or centered in page, or make the color
green etc. As a workaround I'm using label controls.

A quick solution is the following

use response.write("<b>" & "text" & "</b>") for bold
use response.write("<center>" & "text" & "</center>") to center
use response.write("<font color=green>" & "text" & "</font>") to make the
color green

But these are not the best ways to do this. If you got some more time dig
into a technique called CSS = Cascading Style Sheets.
3. May be this is related to the above question. I'm writing the
contents of an array into a multiline textbox, row by row, and
depending on a condition, I want to highlight that row, e.g. if name =
"Michael", highlight, else just write it in the textbox. how to
highlight?

You need a listbox for that, not a textbox. Below is some code that will
give you an idea how to proceed. The code was made with asp.net v2 so maybe
you have to make some changes.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

Protected Sub ListBox1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
Dim thing As ListItem
For Each thing In ListBox1.Items
If thing.Value.Contains("a") Then
thing.Selected = True
End If

Next
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;&nbsp;
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="CategoryName"
DataValueField="CategoryName" OnDataBound="ListBox1_DataBound"
SelectionMode="Multiple">
</asp:ListBox>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString1 %>"
SelectCommand="SELECT [CategoryName] FROM [Alphabetical list
of products]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>


Let me know if you have any more questions..

Cheers,
Tom Pester
 
P

pallabs

Thanks ever so much Tom. Your solutions worked like a charm. Thanks for
the pointer to CSS. Here are some more questions:

1. For (1) above, I'm not controlling the tab sequence in code but I've
just set the indices through the properties pane.

2. I used listbox instead of textbox like you mentioned in (3) above
but now I'm not able to format the display in the manner I want. For
example I want to add a heading to my rows in the listbox and I have

Heading = "#" & ControlChars.Tab & "Items" & ControlChars.Tab &
ControlChars.Tab & "Value of Bids"
lstResult.Items.Add(Heading)

In the screen the control chars (the tabs) are all lost and what shows
up is
# Items Value of Bids

3. I want to refresh the display, say every 15 secs and I'm currently
doing it as:

<meta http-equiv="refresh" content="15">

but if the user is in the middle of entering something on the screen,
it's all lost when he gets back control following a refresh from the
server. This is obviously very annoying for the user. Any better way to
do it? like if the form has been idle for 5 secs only then refresh?

4. This is an auction application and I'm trying to display the elapsed
time on the screen. I've saved the StartTime as an application variable
and am calculating the elapsed time as follows:

Dim Start As DateTime
Dim elapsed As TimeSpan

Start = Application("starttime")

elapsed = Now.Subtract(Start)

ElapsedTime = elapsed.Minutes.ToString & ":" &
elapsed.Seconds.ToString

Now the issue with this implementation is that the elapsed time can
only be incremented when the server is called. If I do it on the client
side by using some javascripts, it becomes dependent on the session.
How can I, may be pass the application start time to the client and
then calculate the elapsed time from the client?
 
T

Tom.PesterDELETETHISSS

1. For (1) above, I'm not controlling the tab sequence in code but
I've just set the indices through the properties pane.

Can you send the code so I can reproduce?
2. I used listbox instead of textbox like you mentioned in (3) above
but now I'm not able to format the display in the manner I want. For
example I want to add a heading to my rows in the listbox and I have

Heading = "#" & ControlChars.Tab & "Items" & ControlChars.Tab &
ControlChars.Tab & "Value of Bids"
lstResult.Items.Add(Heading)
In the screen the control chars (the tabs) are all lost and what shows
up is
# Items Value of Bids

To solve this particular problem you can use spaces instead of tabs and use
a non-proportional font like Courrier so everythin is alligned well.

I suggested you to use the listbox cause I thought you wanted your user to
select certain items in the list and post the information to the server.

If you just want to higlight some items in a list to emphesize things and
don't need your user to select the items themselves we could better use a
datalist.
You understand the difference?

3. I want to refresh the display, say every 15 secs and I'm currently
doing it as:

<meta http-equiv="refresh" content="15">

but if the user is in the middle of entering something on the screen,
it's all lost when he gets back control following a refresh from the
server. This is obviously very annoying for the user. Any better way
to do it? like if the form has been idle for 5 secs only then refresh?

Why do you want to refresh your page every 15 seconds?

Detecting that a form has been idle is possible with Javascript I guess
but required a bit of code.
If I know why you want to refresh i can come up with a simpler solution maybe.
4. This is an auction application and I'm trying to display the
elapsed time on the screen. I've saved the StartTime as an application
variable and am calculating the elapsed time as follows:

People have encountered such requirments in the paste and made some code
for us ready to use :
http://www.google.com/search?hl=en&lr=&c2coff=1&q=countdown+javascript&btnG=Search

There are lots of solutions as you can see. I'm sure there is one that meets
your needs.

Let me know if you have any more questions..

Cheers,
Tom Peste
 
P

pallabs

Thanks again Tom. You are right about the list box. I just need it for
display. So, may be I can use a datalist. Thanks for the poiter to the
javascripts. The tabindex and refresh issues are as follows:

1. About the problem with tabindex, here's the code:
<body bottomMargin="5" bgProperties="fixed" bgColor="lavender"
leftMargin="5" topMargin="10"
rightMargin="5" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:button id="btnLogin" style="Z-INDEX: 101; LEFT: 410px;
POSITION: absolute; TOP: 208px"
runat="server" Font-Names="Verdana" Font-Bold="True" Text="Login"
tabIndex="2"></asp:button><asp:label id="lblPassword" style="Z-INDEX:
105; LEFT: 248px; POSITION: absolute; TOP: 155px"
runat="server" Font-Bold="True" Width="80px" tabIndex="4"
Font-Names="Verdana"
Font-Size="Smaller">Password:</asp:label><asp:textbox id="txtUsername"
style="Z-INDEX: 103; LEFT: 360px; POSITION: absolute; TOP: 104px"
tabIndex="0" runat="server" Font-Names="Verdana" Width="159"
Height="24"></asp:textbox><asp:label id="lblUsername" style="Z-INDEX:
102; LEFT: 248px; POSITION: absolute; TOP: 108px"
runat="server" Font-Bold="True" Width="80px" tabIndex="3"
Font-Names="Verdana"
Font-Size="Smaller">Username:</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 109; LEFT: 360px; POSITION: absolute; TOP: 152px"
runat="server" Width="159px" TextMode="Password" tabIndex="1"
Height="24px"></asp:textbox><asp:label id="lblMsg" style="Z-INDEX: 107;
LEFT: 560px; POSITION: absolute; TOP: 128px"
runat="server"></asp:label><asp:checkbox id="chkPersist"
style="Z-INDEX: 108; LEFT: 568px; POSITION: absolute; TOP: 184px"
runat="server" Visible="False"></asp:checkbox></form>
</body>

2. As I mentioned earlier, this is an experimental auction website, so
I want to refresh the page in order to show the most recent bids. The
auction will be for 15 mnts with potentially heavy bidding. Should I
use a framed page and put the data entry fields and display datalist in
separate frames? So that I can only refresh the frame with the display
field.
 
T

Tom.PesterDELETETHISSS

1. About the problem with tabindex, here's the code:

Sometimes an error is caused by very little details. If you start your tabindex
at 1 and not 0 I think it will work.
For some reason 0 is a value that internet explorer doesnt like.
2. As I mentioned earlier, this is an experimental auction website, so
I want to refresh the page in order to show the most recent bids. The
auction will be for 15 mnts with potentially heavy bidding. Should I
use a framed page and put the data entry fields and display datalist
in separate frames? So that I can only refresh the frame with the
display field.

A framed page is an idea that could solve the problem.
I generaly dislike frames for several reasons so I would look for another
solution (http://www.useit.com/alertbox/9612.html).

I would use a technique called AJAX. Here you have an article on it http://www.devx.com/webdev/Article/28451/0/page/3
What AJAX does is let the browser retreive information from the server without
refreshing the page and rewritting a section of the page without the user
interupting in his current task.

AJAX can be pretty complicated to master so be prepared for a steep learning
curve.
ASP.NET version 2 implements AJAX through "client script callbacks" as showed
on http://www.devx.com/webdev/Article/28451/0/page/3.
If you use version 1 of ASP.NET check out http://weblogs.asp.net/mschwarz/

Mabye an iframe approuch would also work (http://www.dynamicdrive.com/dynamicindex2/iframe-ticker.htm)
but I would go with AJAX.

I hope you don't get lost in AJAX. If you do try the FRAME approuch and see
if you can get a working result.


I hope this helps...

Cheers,
Tom Peste
 
N

newbie

Tom,

your solution for the tabindexing problem was spot on. I'll try out the
other things you've mentioned. thanks a bunch.

pallab
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top