473,503 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tab sequence/highlighting/formatting

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

Nov 19 '05 #1
6 1643

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
Nov 19 '05 #2
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?

Nov 19 '05 #3
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&l...pt&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
Nov 19 '05 #4
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.

Nov 19 '05 #5
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/dynamici...ame-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
Nov 19 '05 #6
Tom,

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

pallab

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7886
by: Mark | last post by:
Hi there, I have a subform, set as a continuous form. When a user selects a particular record in that subform, how can I make that particular record stand out (color or font change, size, etc) from...
9
6044
by: PeteCresswell | last post by:
I've got a continuous form that is a grid of statistical values. When the user clicks on a statistic, something happens (specifically a graph is created showing rolling one-year values for the...
4
4705
by: windandwaves | last post by:
Hi Folk Is there anyone out there who knows if there is an easy way to highlight the currentrecord using conditional formatting or something like that in Access 2003? Thank Nicolaas
2
4724
by: Johnny | last post by:
Sorry I posted this post earlier but got the name and subject the wrong way round (new to this!) so it perhaps didn't look right Sorry for that. But please please answer if you know anything about...
4
2785
by: Patrick Porter | last post by:
Arrrgh! I have tried everything (ok, not EVERYTHING) but i cant get solve the problem of getting syntax highlighting in a rich textbox. in the code below, im attempting to highlight all of the...
3
1521
by: Patrick Porter | last post by:
I am looking at followin the suggestion made by Larry on my last post. (his reply is on the bottom) it seems that you can't directly mess with the rich text header text....specifically the addtion...
4
6089
by: lord.zoltar | last post by:
I am wondering how you guys highlight cells or rows (by changing the text or background colour) in a DataGridView. Right now, I apply styles to certain rows or cells in the CellFormatting even...
4
2657
by: frikker | last post by:
Hello, I have an idea for a project which involves an editor that supports syntax highlighting. This would be for any language, particularly php, html, css, etc. I would like to write this...
1
2502
by: Gord | last post by:
Using VB, when records are brought up in datasheet view (either a query or table), is it possible to highlight (or in some way visually flag) certain records? If so, how is this 'highlighting'...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.