Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Saturday, March 31, 2012

text box cursor position on entry

Hi I want the cursor to align left when someone clicks in textbox.

textbox has maxlength of 7 when user clicks in text box

the cursor is at position 2 so they cant enter all 7 digits of number

without clicking home and reentering number.

It sounds to me like the textbox has some default text in it already. Otherwise, it would be at the left when they click in. Post your code so we can take a look.
As, suggested please check the Text property. By default when you click inside the TextBox is should align to the left at position "0".

add this in page_load...

sub page_load(byval sender as object, byval e as system.eventargs) handles page.load

txt1.text=""

end sub

cheers

moredotnet


thanks for the replies, I have put txtbox.text="" in page load will see what happens.

please use me.load instead of page.load

cheers

moredotnet


How I CAn Change the Cursor Color or Size InHTML TextBox

Thanks


Hi,

call a java script function onfocus, then set the value of text box to null and then call focus function on that control.

hope this would solve your problem


Unfortunately this not solve my problrm

When textbox.value=null ;

the textbox value be "null"


I wanna to write a dataSet as XML File

I use dataset.WriteXML("Filename"); Method

But if ther are an empty cell it will not Writen

Pls. Help Me;


Hi ,

I couldn't get you complete requirement. Can you try like this.

First check whether your data set contain rows are not . If it contains then write to xml file using

ds.WriteXML("filename.xml")

Text Box events

I'm trying to disable one text box when a user starts entering data in
a different text box. Is this even possible? If so can someone point
me towards a good example?
Thanks,
JaimeHi Jaime,
You can diable the first Textbox whenevr you type anything in the second
textbox by using this code:
Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged
Me.TextBox1.Enabled = False
End Sub
Set the AutoPostback property of the second textBox to True and as soon as
the focus from the second textbox is out, the first textbox is disbaled.
Regards,
Manish
www.ComponentOne.com
"jhcruz@.jmaweb.biz" wrote:

> I'm trying to disable one text box when a user starts entering data in
> a different text box. Is this even possible? If so can someone point
> me towards a good example?
> Thanks,
> Jaime
>
"Manish" <Manish@.discussions.microsoft.com> wrote in message
news:A6687B13-88A4-403E-BBD8-37EA92826B7A@.microsoft.com...

> You can diable the first Textbox whenevr you type anything in the second
> textbox by using this code:
> Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles TextBox2.TextChanged
> Me.TextBox1.Enabled = False
> End Sub
> Set the AutoPostback property of the second textBox to True and as soon as
> the focus from the second textbox is out, the first textbox is disbaled.
The above requires a totally unnecessary roundtrip to the server and back...
<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />
private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Attributes.Add("onkeypress", "document.getElementById('" +
TextBox2.ClientID + "').disabled=\"disabled\";");
}
Mark Rae
ASP.NET MVP
http://www.markrae.net

Text box enter

How do I assign a sub to a textbox for when the user hits enter whilst the cusor is still within that textbox?I think you mean how can you execute some code when the textbox is submitted (essentially as event handler). Design your textbox in vs.net...then just double click the textbox and the sub is automatically created for you...then all you have to do is fill in your code.
Hi,

I think you are referring about handling the event for the enter key right?

In your code behind, you will find the handle event for the button click as below:-

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

End Sub

you need to add the textbox's text changed event to it as below:-

Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click, TextBox1.TextChanged

End Sub

This should help you.

Thanks.
Many thanks
your welcome!

did that work for you?

thanks.

Text Box to a Database to a Label

Hi

Im fairly new to ASP.NET, im using 2.0.

I am trying to develop a page where the user can enter text into a multiline textbox and then when they click enter the text is stored in a Table in an SQLServer DB.

When the page is reloaded the text that was stored is outputed to a Label.

This works ok except for one small problem when I entertext in the text box which is more than one line IE

"Hello
my
name
is
Graham"

It is displayed in the Label as "Hello my name is Graham"

Does anyone know how to keep the text in the form that it was entered in the textboxwhen it is displayed in the Label?

Other wise I will not be able to have paragraghs etc, just one long string.

Thanks Graham

The text entered in the multiline textbox has crlf (Carriage Return Line Feed) for line breaks. When you display in html, you must replace those with <br /> to achieve the similar layout.

Hope it helps,

Joe

Text Box Upper Case

Dear All,
How can I force the user to enter only UPPER CASE letters in a
text box
I tried the following in the form load event but doesn't work
TextBox.Text.ToUpper().
Any help much appreciated.
cheers,
Sunil SabirSunil
try
TextBox.Text = UCase(TextBox.Text)
Hope this helps,
Zeeshan Mustafa, MCSD
"Sunil Sabir" <SunilSabir@.discussions.microsoft.com> wrote in message
news:67A81DCD-87CD-45B8-8FEF-E0DF0035B702@.microsoft.com...
> Dear All,
> How can I force the user to enter only UPPER CASE letters in a
> text box
> I tried the following in the form load event but doesn't work
> TextBox.Text.ToUpper().
> Any help much appreciated.
> cheers,
> Sunil Sabir
Sunil,
Another way, if you want the user to see only upper case in the text box
would be to use a RegularExpressionValidator and set the regular expression
to: [A-Z] which will allow only upper case letters.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"M. Zeeshan Mustafa" <zeeshan@.no-spm.please.zeeshan.net> wrote in message
news:evgx%231eXEHA.808@.tk2msftngp13.phx.gbl...
> Sunil
> try
> TextBox.Text = UCase(TextBox.Text)
> --
> Hope this helps,
> Zeeshan Mustafa, MCSD
>
> "Sunil Sabir" <SunilSabir@.discussions.microsoft.com> wrote in message
> news:67A81DCD-87CD-45B8-8FEF-E0DF0035B702@.microsoft.com...
>
>

Text box values are not being considered?

Currently i m working on a web page that edits the user information. The already stored info. from the database is being displayed in diffrent text boxes so that user can edit it. The problem is that even when user changes the information in the any of the text-boxes & clicks the submit button, then instead of current value of text-boxes the previously assigned value is being considered. Whats the possible cause of this error?

Possibly... your records arent getting updated


bh_84:

Currently i m working on a web page that edits the user information. The already stored info. from the database is being displayed in diffrent text boxes so that user can edit it. The problem is that even when user changes the information in the any of the text-boxes & clicks the submit button, then instead of current value of text-boxes the previously assigned value is being considered. Whats the possible cause of this error?

Are they data bound controls? That could be your problem. Since the page load method will run before the click handler, if those databound controls are populated on every post back, they are likely being overwritten there. You will need to only data bind the text boxes when the page isn't posting back.


No they r simple text box controls. values are being assigned to them using text property & not through data binding but still on submiting, the not the current values but the previous ones are being considered.

Doesn't matter if you are databinding or assigning the values yourself. Probably what is happening is the user changes the value and then hits submit to post back the page. At that point your code is setting the Text property for these text values to whatever the initial value is just like it does when you first load the page and is overwriting whatever change the user made. You are probably always setting the values even on postback so you never get the values the user specifies. In your code you need to only set the values if it is not a postback. So something like:

If (!IsPostBack)

{

// Set all textboxes to initial values here.

}

That is C# so if you're using VB you'll need to do the similar thing in VB. This will make sure that when the page is posted back the textboxes don't get overwritten witih the initial values and have whatever values were entered at the browser.

Wednesday, March 28, 2012

text box, command button and required field Validator

there is one text box, command button and one required
field validator control on a web form.
i want user to enter the data in text box i.e it is
mandatory field. so i had used required validator for
this purpose. all works perfectly it gave me the
message that please insert the data etc. but the
problem is that after that i want focus to be put back
on the control. [ please give me the solution keeping
in mind that there could be many such controls on the
form and i want to set focus on respective text box if
user doesn't enter the value for mandatory fiels ]If you want focus back on the textbox, you're in for a lot of work. Its not hard to put focus on the control using javascript, that's easy enough.

The problem stems from what you later ammend to your question (there could be many such controls). Ok... so if there's only one control, that control gets the focus. But if there are five, the fifth one will get focus (because each will apply focus, but the last one to attempt to do so will be the one that wins). And if the last control gets focus, what's the point really - you want it to be user friendly, and the user is going to want to start at the top, not at the bottom of the page.

So you now have a problem - how do you get focus on the first control on what could be a possible list of included controls. For that - you need a way to store the collection of the controls, and some code to determine which is the top-most (first rendered) control that flunked validation and requires focus.

You will need to tip-toe through the server-client architecture, using a combination of code-behind and javascript to do so.

If you wish to explore it further - you best describe more on what your control is (you mention a textbox, validator, and a button - button for each control or one button on the entire page?)

text boxes appearing differently

I am trying to create a simple user control for a person's name, It will ask for first name, middle name, last name, and suffix.
For some reason the text box associated with suffix is appearing with a background of while while all the others have a background of yellow. The properties are all the same for each of the boxes.
I have determined this is due to my google bar. Any idea what I can do to ensure consistency without removing the google bar?
<code>
<html>


First Name:You must enter a first name for the provider
Middle Name:
Last Name:You must enter a last name for the provider
Suffix: (e.g. Jr. , M.D. , etc.)

</html>
</code>

Yep, here ya go:
http://code.jenseng.com/google/

Text boxes and read-only text

I'm wondering what standard/best practices are for the following scenario:
I have a page representing several fields for stored data. If the user has
sufficient access privileges, the page is rendered w/ read/write text boxes
and
they can edit the various fields as needed. However, if the user doesn't ha
ve
sufficient privileges (i.e. view only), the page is rendered w/ the text box
es
set to read-only. However, this results in a rather clunky looking page, an
d
if there is more text in a box than can be rendered w/i the specified box
height, then the user must scroll. Further, when printing the page, the tex
t
is clipped to the box.
So, my thought has been to re-design the page to use two different controls
for
each text field: a text box for read/write, and a label (static text) for
read-only. My thought that it will result in a much cleaner view page, and
printing will be as expected. The negative is that there are then two contr
ols
for each field, and I must hide/show the appropriate control depending on th
e
read-write/read-only status.
Is there a better way to do this that doesn't rely on two controls for each
control?
Thanks for any thoughts and insights.What is your browser base?
If you know that it is IE only..
check out contenteditable... basically it allows any html element to be
editable..
http://msdn.microsoft.com/library/d...enteditable.asp
so you could do
<div contenteditable="true">This text it editable</div>
for those that have read write..
then simply change the flag to false if it is readonly,
This means printing doesnt get cliped either.
To make it so that you can still reference input ins your code you can do
<div contenteditable="true" id="Body" onpropertychange="BodyInput.value =
this.innerText;">This text it editable</div>
<input type="hidden" name="BodyInput" value="">
then you simple get the data from the this.BodyInput.value property on the
server.
Not sure if this is what you are after but it may give you ideas as to where
to go from here.
"Julie" <julie@.nospam.com> wrote in message
news:40A1967F.D6ACF7C2@.nospam.com...
> I'm wondering what standard/best practices are for the following scenario:
> I have a page representing several fields for stored data. If the user
has
> sufficient access privileges, the page is rendered w/ read/write text
boxes and
> they can edit the various fields as needed. However, if the user doesn't
have
> sufficient privileges (i.e. view only), the page is rendered w/ the text
boxes
> set to read-only. However, this results in a rather clunky looking page,
and
> if there is more text in a box than can be rendered w/i the specified box
> height, then the user must scroll. Further, when printing the page, the
text
> is clipped to the box.
> So, my thought has been to re-design the page to use two different
controls for
> each text field: a text box for read/write, and a label (static text) for
> read-only. My thought that it will result in a much cleaner view page,
and
> printing will be as expected. The negative is that there are then two
controls
> for each field, and I must hide/show the appropriate control depending on
the
> read-write/read-only status.
> Is there a better way to do this that doesn't rely on two controls for
each
> control?
> Thanks for any thoughts and insights.
Darren Clark wrote:
> What is your browser base?
> If you know that it is IE only..
> check out contenteditable... basically it allows any html element to be
> editable..
> http://msdn.microsoft.com/library/d...enteditable.asp
> so you could do
> <div contenteditable="true">This text it editable</div>
> for those that have read write..
> then simply change the flag to false if it is readonly,
> This means printing doesnt get cliped either.
> To make it so that you can still reference input ins your code you can do
> <div contenteditable="true" id="Body" onpropertychange="BodyInput.value =
> this.innerText;">This text it editable</div>
> <input type="hidden" name="BodyInput" value="">
> then you simple get the data from the this.BodyInput.value property on the
> server.
> Not sure if this is what you are after but it may give you ideas as to whe
re
> to go from here.
Thanks for the link and info, I'll look into it.
And, yes, my target is IE.

Text boxes and read-only text

I'm wondering what standard/best practices are for the following scenario:

I have a page representing several fields for stored data. If the user has
sufficient access privileges, the page is rendered w/ read/write text boxes and
they can edit the various fields as needed. However, if the user doesn't have
sufficient privileges (i.e. view only), the page is rendered w/ the text boxes
set to read-only. However, this results in a rather clunky looking page, and
if there is more text in a box than can be rendered w/i the specified box
height, then the user must scroll. Further, when printing the page, the text
is clipped to the box.

So, my thought has been to re-design the page to use two different controls for
each text field: a text box for read/write, and a label (static text) for
read-only. My thought that it will result in a much cleaner view page, and
printing will be as expected. The negative is that there are then two controls
for each field, and I must hide/show the appropriate control depending on the
read-write/read-only status.

Is there a better way to do this that doesn't rely on two controls for each
control?

Thanks for any thoughts and insights.What is your browser base?

If you know that it is IE only..

check out contenteditable... basically it allows any html element to be
editable..
http://msdn.microsoft.com/library/d...enteditable.asp

so you could do
<div contenteditable="true">This text it editable</div>
for those that have read write..
then simply change the flag to false if it is readonly,

This means printing doesnt get cliped either.

To make it so that you can still reference input ins your code you can do

<div contenteditable="true" id="Body" onpropertychange="BodyInput.value =
this.innerText;">This text it editable</div>
<input type="hidden" name="BodyInput" value=""
then you simple get the data from the this.BodyInput.value property on the
server.

Not sure if this is what you are after but it may give you ideas as to where
to go from here.

"Julie" <julie@.nospam.com> wrote in message
news:40A1967F.D6ACF7C2@.nospam.com...
> I'm wondering what standard/best practices are for the following scenario:
> I have a page representing several fields for stored data. If the user
has
> sufficient access privileges, the page is rendered w/ read/write text
boxes and
> they can edit the various fields as needed. However, if the user doesn't
have
> sufficient privileges (i.e. view only), the page is rendered w/ the text
boxes
> set to read-only. However, this results in a rather clunky looking page,
and
> if there is more text in a box than can be rendered w/i the specified box
> height, then the user must scroll. Further, when printing the page, the
text
> is clipped to the box.
> So, my thought has been to re-design the page to use two different
controls for
> each text field: a text box for read/write, and a label (static text) for
> read-only. My thought that it will result in a much cleaner view page,
and
> printing will be as expected. The negative is that there are then two
controls
> for each field, and I must hide/show the appropriate control depending on
the
> read-write/read-only status.
> Is there a better way to do this that doesn't rely on two controls for
each
> control?
> Thanks for any thoughts and insights.
Darren Clark wrote:
> What is your browser base?
> If you know that it is IE only..
> check out contenteditable... basically it allows any html element to be
> editable..
> http://msdn.microsoft.com/library/d...enteditable.asp
> so you could do
> <div contenteditable="true">This text it editable</div>
> for those that have read write..
> then simply change the flag to false if it is readonly,
> This means printing doesnt get cliped either.
> To make it so that you can still reference input ins your code you can do
> <div contenteditable="true" id="Body" onpropertychange="BodyInput.value =
> this.innerText;">This text it editable</div>
> <input type="hidden" name="BodyInput" value="">
> then you simple get the data from the this.BodyInput.value property on the
> server.
> Not sure if this is what you are after but it may give you ideas as to where
> to go from here.

Thanks for the link and info, I'll look into it.

And, yes, my target is IE.

Text direction in textbox

Hi guys, is there any property in the textbox control that allows the user to input text in a right-to-left text direction?

Thanks.There is a CSS style attribute calledlayout-flow

In the html header of you page, put the following to control the flow in all form elements (e.g. textboxes included):

<STYLE>
INPUT {layout-flow : vertical-ideographic}
</STYLE>

Monday, March 26, 2012

Text File Processing

I am currently working on a project in which the user will upload a flat file, text file, for processing and manipulation. I am unable to control the format of the test file because it comes from a packaged software. The file is a fixed delimited file that I must read certain value from and write out a new text file in a new format.
The problem that I am having is the starts with a 12 line header that I can through way because the first 12 line will always be the same. Where my problem is that at certain points during the file a sub set of the header file will occur. There does not seem to be any rhyme or reason as to where the entry occurs.
Does anyone have any idea how how to check for this line pattern and how I can ignore it?What I've done in cases like this is to import the file into anintermediary table, delete any rows which contain header information,and insert the remaining records into the final destination table.

Text is not a member of System.Web.UI.WebControls.DropDownList

Ive got a problem here.
I had a script that took user registration info from a form and added it to a database. I had a few issues with relpacing characters and someone gave my some advice on simplifing my script. Now i am having loads of problems with it.
First of all it is now throwing the error above
'Text' is not a member of 'System.Web.UI.WebControls.DropDownList'
Basically i have a dropdown box with counties in it, oh god this asp.net is killing me
Sorry code dump:

<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
Sub btnSubmit_OnClick(Source As Object, E As EventArgs)

If Page.IsValid() Then

Dim sConnection As String
Dim dbConn As OleDb.OleDbConnection
Dim dbCmd As OleDb.OleDbCommand

Dim sqlStatement As String = "INSERT INTO Tblusers ( forename, surname, pass, Email, telephone, mobile, busname, address1, address2, county, postcode ) VALUES (@dotnet.itags.org.forename, @dotnet.itags.org.surname, @dotnet.itags.org.pass, @dotnet.itags.org.email, @dotnet.itags.org.telephone, @dotnet.itags.org.mobile, @dotnet.itags.org.busname, @dotnet.itags.org.address1, @dotnet.itags.org.address2, @dotnet.itags.org.county, @dotnet.itags.org.postcode, , )"

DBCmd.Parameters.Add("@dotnet.itags.org.Forename", TxtForename.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Surname", TxtSurname.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Pass", TxtPass.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Email", TxtEmail.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Telephone", TxtTelephone.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Mobile", TxtMobile.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Busname", TxtBusname.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Address1", TxtAddress1.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.Address2", TxtAddress2.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.county", Txtcounty.Text)
DBCmd.Parameters.Add("@dotnet.itags.org.postcode", Txtpostcode.Text)
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("data\classcampers.mdb")
dbConn = New OleDb.OleDbConnection(sConnection)
dbConn.Open()

dbCmd = New OleDb.OleDbCommand(sqlStatement, dbConn)
dbCmd.ExecuteNonQuery()

dbConn.Close()
End If
end sub
and the top of my form
<asp:DropDownList name="txtcounty" class="searchbox" id="txtcounty" runat = "server">
<asp:ListItem id = "Selected" runat = "server" value = "Selected" selected="true">Select a County</asp:ListItem>
<asp:ListItem id = "Aberdeenshire" runat = "server" value = "Aberdeenshire">Aberdeenshire</asp:ListItem>
<asp:ListItem id = "Angus" runat = "server" value = "Angus" >Angus</asp:ListItem>
<asp:ListItem id = "ArgyllBute" runat = "server" value = "ArgyllBute">ArgyllBute</asp:ListItem>
<asp:ListItem id = "Avon" runat = "server" value = "Avon">Avon</asp:ListItem>
<asp:ListItem id = "Bedfordshire" runat = "server" value = "Bedfordshire">Bedfordshire</asp:ListItem>
<asp:ListItem id = "Berkshire" runat = "server" value = "Berkshire">Berkshire</asp:ListItem>
<asp:ListItem id = "BlaenauGwent" runat = "server" value = "BlaenauGwent" >Blaenau Gwent</asp:ListItem>
<asp:ListItem id = "Borders" runat = "server" value = "Borders">Borders</asp:ListItem>
<asp:ListItem id = "Bristol" runat = "server" value = "Bristol">Bristol</asp:ListItem>
<asp:ListItem id = "Buckinghamshire" runat = "server" value = "Buckinghamshire">Buckinghamshire</asp:ListItem>
<asp:ListItem id = "Cambridgeshire" runat = "server" value = "Cambridgeshire">Cambridgeshire</asp:ListItem>
<asp:ListItem id = "Cardiff" runat = "server" value = "Cardiff" >Cardiff</asp:ListItem>
For some reason the error is falling on the"DBCmd.Parameters.Add("@dotnet.itags.org.county", Txtcounty.Text) "
Anyideas would be great
I still cant replace charaters either
Cheers

That's bcause a DropDownList does not have a property called 'Text'

What it DOES have, however is 'SelectedItem.Text' - - substitute that for 'Text', with your dropdownlist designation -
DBCmd.Parameters.Add("@.county", Txtcounty.SelectedItem.Text)


Thanks for your reply and sorry for the massive code dump but i have spend 4 hours on this
Ive got another error now:

Object reference not set to an instance of an object.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.
Line 45: DBCmd.Parameters.Add("@.Forename", TxtForename.Text)
any ideas this is killing me. It worked before and now it doesnt. I think i am going to cry
Paul

tallpaul101 wrote:

Dim sConnection As String
Dim dbConn As OleDb.OleDbConnection
Dim dbCmd As OleDb.OleDbCommand

Dim sqlStatement As String = "INSERT INTO Tblusers ( forename, surname, pass, Email, telephone, mobile, busname, address1, address2, county, postcode ) VALUES (@.forename, @.surname, @.pass, @.email, @.telephone, @.mobile, @.busname, @.address1, @.address2, @.county, @.postcode, , )"

DBCmd.Parameters.Add("@.Forename", TxtForename.Text)
DBCmd.Parameters.Add("@.Surname", TxtSurname.Text)
DBCmd.Parameters.Add("@.Pass", TxtPass.Text)
DBCmd.Parameters.Add("@.Email", TxtEmail.Text)
DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Text)
DBCmd.Parameters.Add("@.Mobile", TxtMobile.Text)
DBCmd.Parameters.Add("@.Busname", TxtBusname.Text)
DBCmd.Parameters.Add("@.Address1", TxtAddress1.Text)
DBCmd.Parameters.Add("@.Address2", TxtAddress2.Text)
DBCmd.Parameters.Add("@.county", Txtcounty.Text)
DBCmd.Parameters.Add("@.postcode", Txtpostcode.Text)

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("data\classcampers.mdb")
dbConn = New OleDb.OleDbConnection(sConnection)
dbConn.Open()

dbCmd = New OleDb.OleDbCommand(sqlStatement, dbConn)
dbCmd.ExecuteNonQuery()

dbConn.Close()


Ok, there error you are getting tells us that you haven't instantiated a declared variable. In this case it appears to be your OleDBCommand, which you do actually instantiate (in red), but not before trying to add Parameters to it (in green). It appears you just need to repositon some of what you have to be similar to this:

Dim sConnection As String
Dim dbConn As OleDb.OleDbConnection
Dim dbCmd As OleDb.OleDbCommand

Dim sqlStatement As String = "INSERT INTO Tblusers ( forename, surname, pass, Email, telephone, mobile, busname, address1, address2, county, postcode ) VALUES (@.forename, @.surname, @.pass, @.email, @.telephone, @.mobile, @.busname, @.address1, @.address2, @.county, @.postcode, , )"
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("data\classcampers.mdb")
dbConn = New OleDb.OleDbConnection(sConnection)
dbCmd = New OleDb.OleDbCommand(sqlStatement, dbConn) ' Note: sqlStatement should probably be sConnection
DBCmd.Parameters.Add("@.Forename", TxtForename.Text)
DBCmd.Parameters.Add("@.Surname", TxtSurname.Text)
DBCmd.Parameters.Add("@.Pass", TxtPass.Text)
DBCmd.Parameters.Add("@.Email", TxtEmail.Text)
DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Text)
DBCmd.Parameters.Add("@.Mobile", TxtMobile.Text)
DBCmd.Parameters.Add("@.Busname", TxtBusname.Text)
DBCmd.Parameters.Add("@.Address1", TxtAddress1.Text)
DBCmd.Parameters.Add("@.Address2", TxtAddress2.Text)
DBCmd.Parameters.Add("@.county", Txtcounty.Text)
DBCmd.Parameters.Add("@.postcode", Txtpostcode.Text)
dbConn.Open()
dbCmd.ExecuteNonQuery()
dbConn.Close()
By switching around the location of the instantiation you should remove that error. Basically, you can't add properties (query paramaters in this case) to a non-instantiated non-static object.


Ok have done that. I did try to move things around but with no luck

I have moved on now. I get an error now:

Syntax error in INSERT INTO statement.
if i change:
dbCmd = New OleDb.OleDbCommand(sqlStatement, dbConn) ' Note: sqlStatement should probably be sConnection
to what you have said i get the following error:
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'
so i assume that part of it was right. i cant notice anything wrong with the sql statement apart from the fact that i need to strip out spaces in the telephone feild. For now i have just made sure that there are no spaces.
Thanks for your response. This has been killing me
It was working. All i originally wanted to do is strip out any spaces
Thanks Again


I got it
You are a star, thankyou very much
Dont suppose you know why now i have added:
Line 33: DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Text.Replace(" ". ""))
I get the following error
C:\WINDOWS\system32> "c:\windows\microsoft.net\framework\v1.1.4322\vbc.exe" /t:library /utf8output /R:"c:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll" /R:"c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"c:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll" /R:"c:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /out:"C:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET Files\websites_class campers\a6eadb42\22cf6334\ojbpvgwc.dll" /D:DEBUG=1 /debug+ /win32resource:"C:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET Files\websites_class campers\a6eadb42\22cf6334\ojbpvgwc.res" "C:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET Files\websites_class campers\a6eadb42\22cf6334\ojbpvgwc.0.vb"Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4for Microsoft (R) .NET Framework version 1.1.4322.573Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.c:\inetpub\wwwroot\Websites\Class Campers\UserRegistration.aspx(33) : error BC30203: Identifier expected. DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Text.Replace(" ". "")) ~~
Cheers anyway
Paul
Take out Text. I practiced what you ahve there with a string of numbers and then replaced and printed to the screen. Error I got was that Text is not a property of String.
DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Text.Replace(" ". ""))
Should be
DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Replace(" ", ""))
That worked just fine in a Response.Write("".Replace(" ", "")), so unless there is something else that will cause an error, that should work. Looking further, it appears you have a Period (.)between
your parameters (which is what it actually picked up since and it hasn't processed the String.Text property issue yet) instead of a Comma (,).

EDIT: Not sure what I was thinking for part of this. I was assuming TxtTelephone was a String variable rather than a Control of some sort. Yeah, you would do DBCmd.Parameters.Add("@.Telephone", TxtTelephone.Replace(" ", "")) and just the comma is missing, having a period instead..
If I'm not mistaken, in this section:
TxtTelephone.Text.Replace(" ". ""))
that's a period between the two sections - - make it a comma
note: technically, it should work this way - I just normally do any replacement of anything completely before any areas like this, to get it out of the way before any database processing - - but, that's just my preference
Thanks
Its amazing all that time and it was a period instead of a commer.
With regards to manipulating the string before any database stuff is done that is what i was originally trying to do. Oh well ill get rounnd to it.
I have just realised that i will need to check to see if the email address exists and if so send them to a page that says email exists if you have forgotten your password please click here
Its going to be a long road.
Thanks guys i really needed your help
Good one!!

Saturday, March 24, 2012

Text Link User Control

My Usage:

<asp:hyperlink id="lnkNewUser" text="Click Here!" css-class="content_link" OnClick="cmdProcessLogin" /
Doesn't show up. Problem? Wrong Usage? Can't find reference to this control anywhere on the web...the control is missing the runat="server" attribute
You need the runat=server, and there is no text property. Use it like this:

<asp:HyperLink id="HyperLink1" runat="server">HyperLink</asp:HyperLink>
Hi there,

Couple of thing:

1- I beleive there isn't such a thing as "css-class"; Try "CssClass" instead

2- A Hyperlink doesn't have an onclick event. You must want a LinkButton for that. If you need to add a javascript, add it in the code behind in the attributes on the control:

Example: lnkNewUser.Attributes.Add("onclick", "cmdProcessLogin");

3- You need a runat="server".

That should help,

Covo
Hey

Sorry about that post, after so many hours of looking at this thing it I get lazy.

Thanks for the help: <asp:linkbutton id="lnkNewUser" cssclass="content_link" onclick="ShowNewUserForm" runat="server">Click Here!</asp:linkbutton>

text placing directly?

hi guys,

I would like to have my web user control take a piece of text directly from it's calling tag,eg:

<UserControl:Search id="Search" runat="server" SomeText="Text"></UserControl:Search
And have it render this text in it's .ascx file. The .cs file I have looks something like this:

namespace Searching
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

protected string sometext;

public class Search : System.Web.UI.UserControl
{
public string SomeText
{
get { return sometext; }
set { sometext = value; }
}

private void Page_Load(object sender, System.EventArgs e)
{
}
}
}

My question is: How do I get just a plain string to render directly to, for example:

the HERE part?

The actual application of this code is to pass by tag argument the url of a single image and have it render as part of the ascx output.

Thanks,
Matt.Try this:

<%@. Control Language="C#" %>
<script runat="server"
protected string sometext;

public string SomeText
{
get { return sometext; }
set { sometext = value; }
}

private void Page_Load(object sender, System.EventArgs e)
{
thisLink.Attributes.Add( "href", SomeText + ".aspx" );
thisLink.InnerHtml = "goto " + SomeText + " page";
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<a id="thisLink" runat="server"></a>
</form>
</body>
</html>

(I don't actually use C#, so the code might be of poor quality ...)

text searching through html/.apx files in .net

I want to implement search engine that inputs from user then search all html or .aspx file and display results.
Kindly guide me how can i do this.
Any help/sample code will be appreciatedHi,
Take a look @.
-Creating Search Pages with Index Server and .NET

-WhatuSeek.com

HTH

Text Size

I found an issue while working on my asp.net pages in VB. When you open the browser everything looks fine. If a user clicks view and text size and changes the size to larger all my pages are distorted. The text boxes are merged and you cant read them. Does anyone have a solution for this?How are you creating your web page? The pages should look different, but shoudl still be readable. Can you send a short aspx page that demonstrates the behaviour?

Thanks,

Russell
Sounds like you are using GridLayout as you pageLayout (but I could be wrong). I would suggest putting your information (labels and textboxes) in a table. If this dosen't work let me know and I will take a closer look.

Trey
yes I am using a grid layout
I tried to see if there was a difference with a html label or a web form label but they look the same. It seems when the text size is increased by the user it drops the second word in the textbox on another line. How do you know when to use a html label or a web form label?
here a sample

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>trash</title>
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 103; LEFT: 200px; WIDTH: 128px; POSITION: absolute; TOP: 32px; HEIGHT: 30px" cellSpacing="1" cellPadding="1" width="128" border="1">
<TR>
<TD><asp:label id="Label1" runat="server" Width="95px" Height="22px">web form label</asp:label></TD>
</TR>
</TABLE>
<DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 338px; WIDTH: 69px; POSITION: absolute; TOP: 34px; HEIGHT: 25px" ms_positioning="FlowLayout">html
label</DIV>
</form>
</body>
</HTML>
For you table width i would use percents instead of px. I feel it is the best way if you are worried about font size increases. I would also use flowlayout for what you are trying to do. here is an example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>trash</title>
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="50%" align="center" border="1">
<TR>
<TD>
<asp:Label id="Label1" runat="server">Label</asp:Label></TD>
<TD>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

if you give me exactly what you are doing i can see if i can get it working for you.
It looks like that will do the trick thanks a lot.

Text that will appear on a Hyperlink

Hi guys,

Do you know the property on a hyperlink where if the user puts his mouse on the hyperlink, a message will be displayed about that hyperlink. I mean like on this forum, you just hover your mouse pointer on the title of the thread and you will see the message inside. Something like that.

Thanks,

Willy David Jr

ToolTip


Do you mean tooltips?

set it like <a title="tooltips message here" href="http://links.10026.com/?link=http://forums.asp.net/AddPost.aspx?ReplyToPostID=1851390&Quote=False#">LINK</a>


Do you mean tooltips?

set it like <a title="tooltips message here" href="http://links.10026.com/?link=urlhere">LINK</a>


Hi onionpunk,

Thanks for that!

//Willy


For a Hyperlink Button , we have a property called ToolTip where we can give the message that we wish to appear when the mouse is hover on the Hyperlink Button Similarly , if you want to Navigate to the other page when you click the Button , just place the url in Navigate Url property

Text to date conversion

Hi all,

I have a text box I can restrict the user to enter the date in dd-mm-yy hh:mm:ss am/pm

but after taking that How can I make sure that it is a valid date and(date validations) and it should be <=currentdate.

I am inserting it in the oracle data base there it should be in 17-Dec-2003 12:00:01 AM this format.

I know that I can write a function but I am no wise in it could any one please help me out in this. I am really stuck with it

formating date, see sample: http://apriendavisualstudio.net/c/format-datetime-c/


//string strDate="2002-10-03";

//string strDate="10/04/2002";

string strDate="10/05";

DateTime dt = (DateTime)(TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));

Response.Write(" " + dt.DayOfWeek);


Look at the AJAX Control tool kit masked edit control

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx

this ensures your input matches the format you require

Thursday, March 22, 2012

text/image verification question

Anyone know of a software company where I can purchase to integrate into my web site ? This software presents a word in distorted images and user has to type in the corresponding characters for verification that its a real person and not a script.

what you want to search on is CAPTCHA

I used this in the past (http://blogs.clearscreen.com/migs/archive/2004/11/10/575.aspx)