Showing posts with label database. Show all posts
Showing posts with label database. Show all posts

Saturday, March 31, 2012

text box misbehaviour

Hi

I have a text box which provides a parameter for a query which does a search against a database. the text will be populated on load. But if I edit the text box like say add a few letters then the search is not working. So I did the search by doing the test query feature of the wizard giving the exact parameter value ,it gave me the results. So I went back again and deleted everything upto the first first letter and manually re-entered the parameter in the textbox and searched this time I got the results. Seems like there is some hidden values in the TextBox which I have to delete manually . Has anyone come across a situation like this . Please advice how to solve this behaviour.

Thanks

How are you pre populating the textbox?

<asp:TextBox id="foo" runat="server">bla bla bla </asp:TextBox>

or

<asp:TextBox id="foo" runat="server" Text="bla bla bla" />

Note how the first way leads to a phantom space in your textbox...


I am populating it from a dataRow cell.

building1TextBox.Text = BuildingAddressTable[0].BuildingAddress;

What do you think

Thanks


hmm.

What does the Text property look like if you view it in the debugger when it is assigned to your parameter collection? Do you seen any phantom characters?


maybe something like this

building1TextBox.Text = Trim(BuildingAddressTable[0].BuildingAddress);

or

building1TextBox.Text = BuildingAddressTable[0].BuildingAddress.ToString().Trim();

not sure about the syntax - could be just .Trim()

This will trim whitespace from the beginning and end of the specified string.

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 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 field is empty

I'm trying to insert a record on an sql server database table that has
among others a text type field. The insert happens without errors and
all the fields show the correct information except for the text field
when the number of characters is larger than 900. In this case the text
field appears empty. If the text is less or equal to 900 characters
they are inserted with no problem.

In this case have a stored procedure with several input variables
including the text one and a asp.net page with a command that is filled
with the several parameters necessary to run the procedure. One of them
is the text parameter that is defined as follows:

insertcommand.Parameters.Add(New SqlParameter("@dotnet.itags.org.texto", SqlDbType.Text,
2147483647))
insertcommand.Parameters("@dotnet.itags.org.texto").Value = texto.Text
Does someone knows what is causing this problem ?

ThanksHi,

Why do you think it's empty?
Normally, when you use SQL Server Enterprise Manager to
open a table with text field, it shows actual content when
it's <= 900 characters, but <Long Text> when it's > 900
characters. Actual content is in table. If you use Select
query in Query Analyzer, you can see the difference.

Hope it's helpful
Elton Wang
elton_wang@.hotmail.com

>--Original Message--
>I'm trying to insert a record on an sql server database
table that has
>among others a text type field. The insert happens
without errors and
>all the fields show the correct information except for
the text field
>when the number of characters is larger than 900. In this
case the text
>field appears empty. If the text is less or equal to 900
characters
>they are inserted with no problem.
>In this case have a stored procedure with several input
variables
>including the text one and a asp.net page with a command
that is filled
>with the several parameters necessary to run the
procedure. One of them
>is the text parameter that is defined as follows:
>insertcommand.Parameters.Add(New SqlParameter("@.texto",
SqlDbType.Text,
>2147483647))
>insertcommand.Parameters("@.texto").Value = texto.Text
>Does someone knows what is causing this problem ?
>Thanks
>.
Yo're right, Elton. I didn't knew about the EM limitation. Once I used
the QA the information appeared. Thanks!

Text field is empty

I'm trying to insert a record on an sql server database table that has
among others a text type field. The insert happens without errors and
all the fields show the correct information except for the text field
when the number of characters is larger than 900. In this case the text
field appears empty. If the text is less or equal to 900 characters
they are inserted with no problem.
In this case have a stored procedure with several input variables
including the text one and a asp.net page with a command that is filled
with the several parameters necessary to run the procedure. One of them
is the text parameter that is defined as follows:
insertcommand.Parameters.Add(New SqlParameter("@dotnet.itags.org.texto", SqlDbType.Text,
2147483647))
insertcommand.Parameters("@dotnet.itags.org.texto").Value = texto.Text
Does someone knows what is causing this problem ?
ThanksYo're right, Elton. I didn't knew about the EM limitation. Once I used
the QA the information appeared. Thanks!

text file

I have a text file that i have to read and insert into a database table. The
files has over 30 lines of data in it, I need to start inserting data from
line 8 in the file. How can I start inserting the data from line 8 of my tex
t
file? So from line 1-7 are read only (headers) and starting with line 8 need
s
to be inserted into the table.Hi,
you could use StreamReader which has ReadLine method. You could use it to
skip the first 8 lines, and then go about teading it line by line.
StreamReader.ReadLine
http://msdn.microsoft.com/library/d...adLineTopic.asp
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:15EBF9C2-7859-4EEF-A33E-8A64131ABCCC@.microsoft.com...
>I have a text file that i have to read and insert into a database table.
>The
> files has over 30 lines of data in it, I need to start inserting data from
> line 8 in the file. How can I start inserting the data from line 8 of my
> text
> file? So from line 1-7 are read only (headers) and starting with line 8
> needs
> to be inserted into the table.
>

Monday, March 26, 2012

text file

I have a text file that i have to read and insert into a database table. The
files has over 30 lines of data in it, I need to start inserting data from
line 8 in the file. How can I start inserting the data from line 8 of my text
file? So from line 1-7 are read only (headers) and starting with line 8 needs
to be inserted into the table.Hi,

you could use StreamReader which has ReadLine method. You could use it to
skip the first 8 lines, and then go about teading it line by line.

StreamReader.ReadLine
http://msdn.microsoft.com/library/d...adLineTopic.asp

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:15EBF9C2-7859-4EEF-A33E-8A64131ABCCC@.microsoft.com...
>I have a text file that i have to read and insert into a database table.
>The
> files has over 30 lines of data in it, I need to start inserting data from
> line 8 in the file. How can I start inserting the data from line 8 of my
> text
> file? So from line 1-7 are read only (headers) and starting with line 8
> needs
> to be inserted into the table.

text formatting?

I have an SQL database where I'm pulling up some long paragraph cells. I was wondering how I might be able to format the text within these cells... if this is possible. For instance, if there is a website, I would like to make it an active link…. or I might want to bold something and put in a button to do so.
I know this is probably very complicated but I was wondering if anyone knows where or what I should start reading to be able to do something like this? Any points or ideas would be greatly appreciated! Thanks in advance!
RayMaybe the easiest way would be to put tags into the text, and store the text as HTML within the server. Then, when you pull it out, just make sure you display it as HTML and not just text. This would mean that you would have to manually style the text and type all the tags before storing it into the server.

HTH

Jags
yeah thats what I've been doing right now, it works but I thought there might be a better way. Thanks.

text formatting problem

hi guys,
I realized that whenever the text content of a database is loaded, its formatting (like paragraphing and alignment) is lost! How can I preserve these formattings?

cheersassign the output of the field into a variable (like: strFieldResults)

then, do a replace function on the contents:

strFieldResults=strFieldResults.Replace(vbcrlf, "<br>")

Each line feed separation is stored as a 'vbcrlf' -- - the browser doesn't understand that, so you need to replace these with the HTML LINE BREAK tag, so the browser will understand them.
ic...thx
hi augustwind,
I've tried the code you've given me but it doesn't seems to work. Instead of giving me a line break, it simply inserts a space in between the paragraphs. Do u have any working example of the code which i can reference to?
Use a Css Style sheet and set all your objects to the style you want.

like

.button{background-color: #000099; }

and then in your webform set button1's cssclass to button.

hope that helps
~
hi sausykat,
think you've misunderstood my question. My problem is that whenever the content from my database is loaded, the text's formatting is always lost. So I was asking how can I retain those formattings.

But however, you brought out an interesting point about using the css style sheet to customise the object's style--something which I didn't know how to use either.
So may I ask you where can I learn more about using css style sheet? Do you have a good tutorial for it or something?

Thanks for your help.
Most of what i've learned so far on style sheets are from the MSDN library and different forums i've jumped on.

Text if not null

I want to display text in a datagrid based on if the text pulled in from the database is null or not.

Below I can change the backcolor if its not blank but I want to change the text :

Put "Confirmed" if it is not null, and "Not Confirmed" if it is null.

Dim conf As String
conf = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "confirm_id"))

If conf <> "" Then
e.Item.BackColor = System.Drawing.Color.AliceBlue

End If

How can I do this?Try (3 is just an example, you'll have to use the right column index)
e.Item.Cells[3].Text = "Confirmed"

Regards
Fredr!k
I got the following error:
'Cells' is not a member of 'System.Web.UI.WebControls.DataListItem'.

I am using a datalist is there a way of doing this with a datalist?

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 manipulation

Hi,

Senario: I'm retrieving some text from a database and when I display
this text on my page I want the first paragraph to be a different
color.

Do I need to break up the values i.e. find where <br><br> occurs and
substring up to this point. Then have two labels on the form??

or is there an easier method?

Thanks!

Jack"jack-e" <jack-b@.humlog.com> wrote in news:1123565399.992699.270660
@.g47g2000cwa.googlegroups.com:

> Hi,
> Senario: I'm retrieving some text from a database and when I display
> this text on my page I want the first paragraph to be a different
> color.
> Do I need to break up the values i.e. find where <br><br> occurs and
> substring up to this point. Then have two labels on the form??

Depending on how complex the search is, Regular expressions maybe a better
choice than substrings.

As for color coding, you can try:

-Style sheets, assign each paragraph to their own CSS class
-Rather than use two labels, you can just append some HTML to the database
text and place the results into a literal.

But in short, using two labels works just as well : )

--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
do you know how would i use a regular expression to find when a
paragraph finishes? (or begins?)
"jack-e" <jack-b@.humlog.com> wrote in message
news:1123568497.239674.83420@.z14g2000cwz.googlegro ups.com...
> do you know how would i use a regular expression to find when a
> paragraph finishes? (or begins?)

Depends entirely on how the paragraphs are encoded. Earlier you implied
two consecutive <br> tags, for example. Whenever I write paragraphs in HTML,
I enclose them in <p> and </p>, so looking for two <br> tags would not work
with my data.

- Oliver.

text manipulation

Hi,
Senario: I'm retrieving some text from a database and when I display
this text on my page I want the first paragraph to be a different
color.
Do I need to break up the values i.e. find where <br><br> occurs and
substring up to this point. Then have two labels on the form'
or is there an easier method?
Thanks!
Jack"jack-e" <jack-b@.humlog.com> wrote in news:1123565399.992699.270660
@.g47g2000cwa.googlegroups.com:

> Hi,
> Senario: I'm retrieving some text from a database and when I display
> this text on my page I want the first paragraph to be a different
> color.
> Do I need to break up the values i.e. find where <br><br> occurs and
> substring up to this point. Then have two labels on the form'
Depending on how complex the search is, Regular expressions maybe a better
choice than substrings.
As for color coding, you can try:
-Style sheets, assign each paragraph to their own CSS class
-Rather than use two labels, you can just append some HTML to the database
text and place the results into a literal.
But in short, using two labels works just as well : )
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]
do you know how would i use a regular expression to find when a
paragraph finishes? (or begins?)
"jack-e" <jack-b@.humlog.com> wrote in message
news:1123568497.239674.83420@.z14g2000cwz.googlegroups.com...
> do you know how would i use a regular expression to find when a
> paragraph finishes? (or begins?)
Depends entirely on how the paragraphs are encoded. Earlier you implied
two consecutive <br> tags, for example. Whenever I write paragraphs in HTML,
I enclose them in <p> and </p>, so looking for two <br> tags would not work
with my data.
- Oliver.

Text Message Data

HI Guys,
I am quite puzzled at the following issue:

I have a .net application linked to SQL database in back end. In database we
have records for clients and their associated Projects.There is a need that
came up and the company wants us to provide SMS based functionality where an
exec can type in keyword on their phone and send it and recieve small
description regarding the client and project on their phone similar to Google
SMS.

Can someone please tell me how this can be done?

Thanks a million in advance.

Manny=?Utf-8?B?TWFubnkgQ2hvaGFu?= <MannyChohan@.discussions.microsoft.com>
wrote in news:044285CD-21E8-492B-8203-0EA9891CB4E3@.microsoft.com:

> I have a .net application linked to SQL database in back end. In
> database we have records for clients and their associated
> Projects.There is a need that came up and the company wants us to
> provide SMS based functionality where an exec can type in keyword on
> their phone and send it and recieve small description regarding the
> client and project on their phone similar to Google SMS.
> Can someone please tell me how this can be done?

Here are a couple options:

1. Easiest - SMS Gateway (google search SMS gateways, ClickATel is one
example).
Gateways allow you to send messages via serveral formats, through
e-mail, web service, sockets, or through SMS messaging protocols

2. Hook a SMS compatible phone to your server and send messages via the
phone using an ActiveX (or .NET) object

3. Interface directly with your mobile phone company's SMS gateway
(IP*Works has such a component)

I would choose option #1... while slightly expensive (about 5 - 10c a
message), you get high reliability and ease of interface.

For SMS to propogate between networks (say for example AT&T and Verizon)
there needs to be a peering contract between the two companies. If there
is no peering, no messages with get through. Large commerical SMS
providers do the peering internally and route the messages to the proper
outbound gateway to ensure delivery.

Couple catches - if you're in North America, many carriers do not
consider SMS to be mission critical... you might notice things from
message slowdowns (takes hours for delivery to occur) to messages
outright disappearing! Also different commerical providers (depending on
where they're located and how their peering is setup) will affect their
delivery times and reliability.

--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Text Message Data

HI Guys,
I am quite puzzled at the following issue:
I have a .net application linked to SQL database in back end. In database we
have records for clients and their associated Projects.There is a need that
came up and the company wants us to provide SMS based functionality where an
exec can type in keyword on their phone and send it and recieve small
description regarding the client and project on their phone similar to Googl
e
SMS.
Can someone please tell me how this can be done?
Thanks a million in advance.
Mannyexamnotes <MannyChohan@.discussions.microsoft.com>
wrote in news:044285CD-21E8-492B-8203-0EA9891CB4E3@.microsoft.com:

> I have a .net application linked to SQL database in back end. In
> database we have records for clients and their associated
> Projects.There is a need that came up and the company wants us to
> provide SMS based functionality where an exec can type in keyword on
> their phone and send it and recieve small description regarding the
> client and project on their phone similar to Google SMS.
> Can someone please tell me how this can be done?
Here are a couple options:
1. Easiest - SMS Gateway (google search SMS gateways, ClickATel is one
example).
Gateways allow you to send messages via serveral formats, through
e-mail, web service, sockets, or through SMS messaging protocols
2. Hook a SMS compatible phone to your server and send messages via the
phone using an ActiveX (or .NET) object
3. Interface directly with your mobile phone company's SMS gateway
(IP*Works has such a component)
I would choose option #1... while slightly expensive (about 5 - 10c a
message), you get high reliability and ease of interface.
For SMS to propogate between networks (say for example AT&T and Verizon)
there needs to be a peering contract between the two companies. If there
is no peering, no messages with get through. Large commerical SMS
providers do the peering internally and route the messages to the proper
outbound gateway to ensure delivery.
Couple catches - if you're in North America, many carriers do not
consider SMS to be mission critical... you might notice things from
message slowdowns (takes hours for delivery to occur) to messages
outright disappearing! Also different commerical providers (depending on
where they're located and how their peering is setup) will affect their
delivery times and reliability.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]

Text Masking

What is the easiest way to apply a Mask to data in ASP.NET. I have Phone Numbers stored in 5555555555 format in the database, and when I load them I'd like to mask them, where applicable, as (555) 555-5555. Is there an easy way to do this or am I gonna have to write something custom to do it?Take a look at the String.Format method it has everything you want and more!

String formatting in C# (http://www.stevex.org/CS/blogs/dottext/articles/158.aspx) -> C# article but still applies to VB.NET. It even has an example for phone numbers!

HTH

DJ
Thanks, that helps on the output. Still looking for thoughts on Input Masking as well. I've converting an old Access App to a SQL/ASP.NET app, and alot of the fields were masked to a certain input. I can do regular expression validators, but what a hassle to right them for every input and even then it doesn't seem as intuitive.
Could you give some more details of what you are doing - I don't understand why the above wouldn't work for the situation you describe. Perhaps I've misunderstood.

DJ
No, that will work great for when I output from the database. I'm just trying to figure out a way to mask data on input. For example, in this Access app I am converting to ASP.NET, for a phone number, it has an text field that looks something like: (___) ___-____ , where it restricts (masks) input.
Your best bet is to use javascript. I don't know if you are good with JS or not, but I am sure you could find sample code for formatting a phone number using it.

I recommend this because it will be 100% client side formatting, and won't be a drag on your webserver. If you were to make the input box run at the server, and put code in its textchanged event, each time they type a number in the box it would post back to your webserver. Javascript will simply do everything client side. it would be the onchange event of the input tag that you would want to perform the formatting. Basically you look at the entered string, get all the numbers in it, and if the numbers length is 10, then you have potentially a valid phone number and should format it, otherwise do not.

Text overflow in Div

Hi guys

Am new to asp.net. I am tryin to display some information from database into a label element , issue is the text gets overflow rather wrapping within the element(as in notepad).

any help/advice much appreciated

-->

<divid="columnright">

<divclass="rightblock">

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:SwapNetDB %>"

SelectCommand="SELECT id, itemdate, title, description, photo, albumid, staticURL FROM Announcements WHERE (id = @dotnet.itags.org.id)">

<SelectParameters>

<asp:ParameterType="Int32"DefaultValue="1"Name="id"></asp:Parameter>

</SelectParameters>

</asp:SqlDataSource>

<asp:FormViewID="FormView1"runat="server"DataSourceID="SqlDataSource1"DataKeyNames="id"

OnDataBound="FormView1_DataBound">

<ItemTemplate>

<h3>

<asp:LabelHeight="100px"Text='<%# Eval("title") %>'runat="server"ID="titleLabel"/>

</h3>

<divclass="itemdetails">

<p>

<asp:LabelText='<%# Eval("itemdate","{0:D}") %>'runat="server"ID="itemdateLabel"/>

</p>

</div>

<p>

<asp:labelBorderStyle="None"BackColor="transparent"Text='<%# Eval("description") %>'runat="server"ID="descriptionLabel"/>

</p>

</ItemTemplate>

</asp:FormView>

ID="LinkButton4"runat="server"OnClick="prevButton_Click">« Previous Article</asp:LinkButton>

</div>

</div>

Css info:

.leftblock

{

border:1pxsolid#DBDB79;

padding:15px;

margin-bottom:10px;

background:#FEFAABurl(../../images/background_columnleft.gif)repeat-y;

vertical-align:top;

}

.leftblockh2,.rightblockh2,.fullwidthh2

{

font-size:1.6em;

}

#columnleft

{

float:left;

width:240px;

/*position: relative; */

}

#columnright

{

margin-left:245px;width:446px ;

/*position: relative; */

}

.rightblock

{

border:1pxsolid#DBDB79;

padding:0px;

margin-bottom:1px;

margin-right:1px;

background:#FEFFABurl(../../images/background_columnright.gif)repeat-y;position:relative;

}

any help much appreciated

Labels render as an html <span> element. Apply a width to it.

Text Truncation

hi,
I have a dataview which is returning the shipdate information like
01/23/2005 10:23:23 from the database , i need to truncate the time
part of the ship date information ,
currently i am using..
I am creating a separate column at runtime and and assigning the ship
date information to that new column ,
Always String has a remove function which truncates the characters, but
how do i do that for a ROW..
If you guys have a better solutions , i ll appreciate your help

Attached is my code:

DataColumn myCol3 = dvResults.Table.Columns.Add("ShipDate1");
DataRow ship;
dvResults.Table.Columns.Add(myCol3);
for(int i=0;i<dvResults.Table.Rows.Count;i++)
{
dvResults.Table["ship"] =
dvResults.Table.Rows[i]["Ship_Date"].ToString;
}
Thanks
polurIf it's already a datetime format, you could cast or convert it to a
System.DateTime. Then just use the ToShortDateString() method which will
only return the date, not the time part.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"manas" <mahesh.manas@.gmail.com> wrote in message
news:1120256123.749385.86050@.g43g2000cwa.googlegro ups.com...
> hi,
> I have a dataview which is returning the shipdate information like
> 01/23/2005 10:23:23 from the database , i need to truncate the time
> part of the ship date information ,
> currently i am using..
> I am creating a separate column at runtime and and assigning the ship
> date information to that new column ,
> Always String has a remove function which truncates the characters, but
> how do i do that for a ROW..
> If you guys have a better solutions , i ll appreciate your help
> Attached is my code:
> DataColumn myCol3 = dvResults.Table.Columns.Add("ShipDate1");
> DataRow ship;
> dvResults.Table.Columns.Add(myCol3);
> for(int i=0;i<dvResults.Table.Rows.Count;i++)
> {
> dvResults.Table["ship"] =
> dvResults.Table.Rows[i]["Ship_Date"].ToString;
> }
> Thanks
> polur

Thursday, March 22, 2012

text.Replace("\n", "<br />") does not work

I have some problems figuring out the ASP.NET's version of 'nl2br'. I have some text paragraphs in a MSSQL database. When it is output, the line breaks are unnoticed in the *.aspx page.

I already tried using 'newtext = text.Replace("\n", "<br />")', but unfortunately the line breaks are still ignored. I have been searching for "\n" in the text paragraphs using 'indexOf', but it still could not find any line breaks (result: -1).

Does somebody have a hint? Thanks!Can you post the method in which the 'newtext = text.Replace("\n", "<br />")' line of code is?
If a user types text into a textbox and the text "wraps", those arenot line breaks.

Could that be the problem?
Yes, I use 'wraps'... should I use the HTML control 'Textarea' instead?

I have two aspx files: 'first.aspx' and 'output.aspx', which code can be seen here under. The purpose is to create a HTML file. The first file put the text into the database, and the second file creates a HTML file of the regarding text.

(in first.aspx)
Dim text2 As TextBox = New TextBox
text2.ID = "text2"
text2.TextMode = TextBoxMode.MultiLine
text2.Columns = 40
text2.Rows = 3
text2.Wrap = True
Panel1.Controls.Add(text2)

(regarding text in MSSQL)
blah blah blah blah

blah blah blah blah

(in output.aspx)
newText = text.Replace("\n", "<br />")
FileWriter.WriteLine("<p><h5>" + newText + "</h5></p>")

(in the created file: 'newfile.html')
<P>
<H5>
blah blah blah blah

blah blah blah blah
</H5>
</P>
Well, text wraps will not be "saved" as newlines. So the text.Replace you've shown will only work if the user actually pressed Enter to create a newline.

If you want the output page's <h5> to wrap the text, then you'll need to give the <h5> a "width" ... so that it wraps in a similar place as the input page's textbox.

 FileWriter.WriteLine("<p><h5 style=""width:200px"">" + newText + "</h5></p>")
Does that help?
thanks for your reply... unfortunately it does not help. I pressed 'Enter' to create newlines, but it does not work.

About the second point: the width should not make difference since the user creates the newlines.

Maybe it is because of the 'Data Type' of the MSSQL, although I tried 'text' and 'varchar', but both of them does not work.
In that case, try usingHttpUtility.Encode before saving the text to your database.

Then, after retrieving this text from the database, apply theHttpUtility.Decode method to the text.

Then, finally, run your newline replace method, to insert the necessary <br /> tags.
tnx again for reply, and again, it does not help... maybe the cause can be found in the functions that puts the text into and out of the database, as seen below...

Again, the 'newlines' are displaying in the database itself (empty line). Besides, the empty lines also appear in the output file.

['put into database' function]


Private Sub newFunction2(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim MyConnection As SqlConnection, 'etc
Dim text2 As TextBox = CType(Page.FindControl("text2"), TextBox)

Dim text2Text As String = HttpUtility.HtmlEncode(text2.Text)

MyConnection = New SqlConnection(connectionstring)
MyCommand = New SqlCommand("insert into buffer1 (type,text) VALUES ('text','" & text2Text & "') ", MyConnection)

MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
MyCommand.Connection.Close()

End Sub

['get from database' function]


Private Sub Page_Load(ByVal sender ...
'etc etc
For Each DR In DS.Tables(0).Rows
Dim type As String = DS.Tables(0).Rows(i)("type").ToString()
Dim text As String = DS.Tables(0).Rows(i)("text").ToString()

If type = "text" Then
Dim text2 As String = HttpUtility.HtmlDecode(text)
text2Text = text2.Replace("\n", "<br />")
FileWriter.WriteLine("<p><h5>" + text2Text + "</h5></p>")
'etc etc


Hang on. I think\n is a C# construct. I don't think it will work in VB.NET.

Try using the following line instead:

 text2Text = text2.Replace(System.Environment.Newline, "<br />")

Yes. That was the missing link. Thanks!

Tuesday, March 13, 2012

TextBox - Database

Hi All

I have got a registration form..where new Users create the new user IDs...

I just want to check whether the username exists in the database as soon as the user leaves the textbox .

Please help.

Thanks

Asif Ali.

Are you using ASP.NET 2.0 Membership?

Or are you doing things yourself in a SQL table?


HI there

I m doing thing son my own on access database.

Thanks

Asif Ali.


TextBox - Database

Hi Kaushal

U havent seen my question properly.

And also in future please abstain from answering my Q's.

Thanks

Asif.


acube82:

Hi Kaushal

U havent seen my question properly.

And also in future please abstain from answering my Q's.

Thanks

Asif.

oh... i am so so so so so sorrryyy... if you have read the sample code which i have posted before... that was written in btnLogin_Click event... (but we should have that much knowledge that we can write this code event in textbox_chanage event with autopostback tru for textbox)... the code was about select query run against database which would return the datareader if there would be any user in the database with the same name (by checking reader.hasrows) other wise ... it will go to goto label "invaliduserpass" (we should have that much common knowledge that we can change it to msg like "user name already exists..".. anyway... your quote posted will be taken care of in future... thanx..


Ahh, did you get an answer to your question?

Basically (as I think was stated above)... you'd just want to run a SQL query against you're table to see if the username already exists... if you need help with that let me know :)


Since, you want that if the user exists or not as soon as the user leaves the textbox you can make use of AJaX calls. If you are using ASP.NET 2.0 then you can use client callbacks. Using AJAX your page won't refresh and you will know whether the user exists or not. Let me know if you need further details.


Hi...Azam...

I m a beginner..So not into AJAX at the moment.

If U can help me out, will be highly appreciated.

Thanks

Asif Ali.