On a click event, I need to test certain text boxes and then based on their
values go to another text box. How do you set the focus using vb?
--
Thanks in advance,
StevenLook at the "Focus in WebForms" thread earlier today...
On a click event, I need to test certain text boxes and then based on their
values go to another text box. How do you set the focus using vb?
--
Thanks in advance,
StevenLook at the "Focus in WebForms" thread earlier today...
Private Sub cmdAddLine_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdAddLine.Click
lstLines.Items.Add(PhoneFormat(txtAddLine.Text))
txtAddLine.Text = ""
setFocus(txtAddLine)
End Sub
Public Sub setFocus(ByVal ctrl As System.Web.UI.Control)
Dim strS As String
strS = "<SCRIPT language='javascript'>document.getElementById('" +
ctrl.ID + "').focus();</SCRIPT>"
RegisterStartupScript("focus", strS)
End Sub
This will not place the focus in the textbox. What am I missing?
Again, PLEASE help. Thanks much!On 7 Jul 2004 10:42:20 -0700, JC <ujjc001@.charter.net> wrote:
> Hello-
> I have a form which has a listbox, a textbox and a submit button. The
> user types a phone number into the textbox, clicks button, text gets
> added to the listbox. After this process I need the focus to be back
> in the textbox. Sounds easy hu?
> Here's my code-
> Private Sub cmdAddLine_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdAddLine.Click
> lstLines.Items.Add(PhoneFormat(txtAddLine.Text))
> txtAddLine.Text = ""
> setFocus(txtAddLine)
> End Sub
> Public Sub setFocus(ByVal ctrl As System.Web.UI.Control)
> Dim strS As String
> strS = "<SCRIPT language='javascript'>document.getElementById('" +
> ctrl.ID + "').focus();</SCRIPT>"
> RegisterStartupScript("focus", strS)
> End Sub
> This will not place the focus in the textbox. What am I missing?
> Again, PLEASE help. Thanks much!
Do you get a JS error? I assume you are; your control will get a unique
client ID that .NET creates on the actual HTML, so you can't just look for
ctrl.ID. Try ctrl.ClientID
http://msdn.microsoft.com/library/e...rmscontrols.asp
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
gah, dang sig...ignore, just testing/updating my sig correctly..
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
On 7 Jul 2004 10:42:20 -0700, ujjc001@.charter.net (JC) wrote:
>Hello-
>I have a form which has a listbox, a textbox and a submit button. The
>user types a phone number into the textbox, clicks button, text gets
>added to the listbox. After this process I need the focus to be back
>in the textbox. Sounds easy hu?
>Here's my code-
>Private Sub cmdAddLine_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles cmdAddLine.Click
>lstLines.Items.Add(PhoneFormat(txtAddLine.Text))
>txtAddLine.Text = ""
>setFocus(txtAddLine)
>End Sub
>Public Sub setFocus(ByVal ctrl As System.Web.UI.Control)
>Dim strS As String
>strS = "<SCRIPT language='javascript'>document.getElementById('" +
>ctrl.ID + "').focus();</SCRIPT>"
>RegisterStartupScript("focus", strS)
>End Sub
>This will not place the focus in the textbox. What am I missing?
>Again, PLEASE help. Thanks much!
Put a blank label at the bottom of the form and set its text property
in the codebehind instead of using the registerstartupscript.
-Adam
:o) You're all wrong. I took and made a clean application and it
worked, so I knew it wasn't the code there. I went back to my app,
(made a copy) and proceded to strip everything out until it worked.
Well, after everything was gone it still didn't work. There was only
one remaining thing, smartnavigaion = true.
That fixed the focus problem by turning it off, however it introduced a
whole new set of problems.
Having a database application, the users need to not use the back
button. I've got all the standard code for this but it's still not as
clean as smartnav.
Is there ANY way to overcome smartnav's focus problem?
MICROSOFT??
I didn't think so.
Anyhow, I've solved one problem only to intoduce many more. I may have
more ?'s soon, some really good ones I've been working on. Thanks for
the help so far.
Jeff
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
In the past I worked on a project where we wanted a report to automatically print "landscape". We had to install a DLL on the client to get this to work, since the printing attributes are set in the client-machine's registry.
From then to now, I don'tthink there has been any script or CSS properties exposed to allow this to be done.
HTH...
Chris
P.S. - one to to try would be to render your data in HTML tables, centered with fixed width's (the smaller the width, the larger the "margin"). Not sure how elegant of a solution that is, but it should work.
Does anyone know if some javascript might do the above? Still looking for a solution. Thanks!
Don't let the title fool you, ...here is a small excerpt from the article (below):
Basically, changing printing options DOES involve changing registry settings on the client machine.
Here is one possible solution (it requires a third-party component though, like I described in my previous post):
HTML Printing
HTH...
Chris
Chris,
Thank you for the additional info. I will check it out.
I have been searching for something similar and, like you have not had too much luck. I did find a third party product that lets you have limited control of print setting for free, and more control if you pay...
link:
http://www.meadroid.com/scriptx/indexa.htm
What other options does a developer have for internet base printing? Has anyone had experiences with dynamic acrobat compilers? How about creating MS Snapshot reports dynamically from an asp page?
I can't believe there is nothing else out there.
The Mead control is the one I used in the past...like you said, limited control for free, more for the paid version.
Honestly though, I haven't found anything else that does the job any better (for true browser based printing). Seems if you truly want to control the print job, you need to use some custom control to generate the doc (like PDF of Crystal reports or something).
Chris
regarding using acrobat or crystal to generate a doc ...
do you mean generate a doc on the client-side or the server-side?
You would really most likely want to generate your reports server-side, where you have a better idea of system configuration/power (as well as control over more of the process). You can't count on a user having a fast machine ;-)
HTH...
Chris