|
Well, you should answer the OP, not me. This code also has some big issues. First of all, it is prone to crashing. Never use int.Parse, always use int.TryParse. It's also way too many lines, I could write it in a lot less. Finally, won't it crash if the file does not exist ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
then what is the best solution
|
|
|
|
|
A text file is an OK solution, if the website doesn't have a database behind it
1 - check if the file exists before you open it, if not create it
2 - use int.TryParse so that if the file is corrupt, it resets rather than blow up the site
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
You need some kind of locking. This is not thread safe.
|
|
|
|
|
I was trying not to get too confusing
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
i did not get.could u send me the sample code.i just want to display the number of hits in asmal table or in any graphical image
|
|
|
|
|
I'm sorry, someone gave code, I corrected it, if you can't work it out, then I don't know what else to say.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Best method would be using services like Google analytics[^]. If you want to implement your own tracker, better use database to keep the information, you don't need to worry about thread safety. But keep it in mind, if the application is getting good hits, your database will become huge in size.
|
|
|
|
|
hi guys
i have one problem .
i want to upload a pdf file and want pages of this pdf file as a images in asp.net.
means i have a pdf file and this file have 5-6 pages.and when i will upload this file ,i want these all pages should be upload as separate image in database.
because i want to show all pages in thumbnails images.
if any one of u can help me then it will be gr8 for me
thanks
Ajay Rathi
software engineer
NOIDA(UP),INDIA
|
|
|
|
|
You need to buy a PDF library then
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have a function in an ASP.Net project that sets the date in a text box. ie
<br />
Private Sub SetDate()<br />
Dim dateTimeFormatInfo As DateTimeFormatInfo = cultureInfo.CurrentCulture.DateTimeFormat<br />
Dim dateStartDate As Date = Date.Now<br />
txtStartDate.Text = dateStartDate.ToString("d", dateTimeFormatInfo)<br />
End Sub<br />
In my web.config I have:
<br />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" uiCulture="en" culture="en-US" /><br />
When I run this locally I get the expected short date format, namely m/d/yyyy (on Windows XP SP2 using the VS web server). However when I run it on IIS on Windows 2003 the date is always formatted as dd/MM/yyyy. I thought this may have been something to do with regional settings on the server so I changed this. No difference. I tried uninstalling and reinstalling the .Net 2.0 framework but to no avail. When I do a:
<br />
Dim dateTimeFormatInfo As DateTimeFormatInfo = cultureInfo.CurrentCulture.DateTimeFormat<br />
Response.Write(dateTimeFormatInfo.ShortDatePattern)<br />
it is always output as dd/MM/yyyy. I know you can manually set the ShortDatePattern however I would prefer to know why this isn't working as expected. It's probably something incredibly trivial that I have overlooked. Any advice much appreciated.
Thanks.
|
|
|
|
|
Hi,
Can any one provide me the information about,
What is dash board, Portals.. How to deveop them? And any real world example of where we use them?
Thanks in advance
|
|
|
|
|
Please read the article linked to in my sig.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Hi all,
I have created a custom web control that inherits from ListBox. My control has a property "LinkListBox" which is of type ListBox. When I dump my new control on a form, I can see the property, and when I select it, it lists all objects of type ListBox on the webform. 100% to now.
When I select a listbox from the dropdown however, I get the error
"Cannot create an object of type 'Savitar.Web.UI.WebControls.ListBox" from it's string representation 'ListBox1' for the 'LinkedListBox' property."
I have been googling for hours now to find a simple solution to this problem, and come across custom type converters etc... but just not managing to get anything to work.
My property looks as follows...
public ListBox LinkedListBox
{
get { return _LinkedListBox; }
set { _LinkedListBox = value; }
} ListBox _LinkedListBox = null;
Please would someone assist. Frustration is starting to kick in big time
|
|
|
|
|
Your issue is at design time, or run time ? Do people actually use the designer to create web forms ?
Michael Smit wrote: "Cannot create an object of type 'Savitar.Web.UI.WebControls.ListBox" from it's string representation
This makes me think you need to support serialisation for your control.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The problem is at design time.
And ye... People definitely use the designer. We code in directly in the markup too, but only when necessary.
|
|
|
|
|
Hi,
I have a webpage that has a remove button and everything works fine in it. But I want too add a simple(Are you sure[Yes, No]) alert to the button in the client side script for the button.
I searched in google but most things were about implementing client-side scripting for HTML server controls and I am a little bit confused on how to do a conditional postback for the page.
How can I implement a conditional Postback of the page using an alert??
Thanks
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
If you add an OnClientCLick method to a button, the postback will only occur if the client side method returns true.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you very much, it worked perfectly
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hello Friends.
I'm Arunvijay .. have to Upload a file into DataBase using FileUpload control .
can anyone help me...
ArunVijay
|
|
|
|
|
|
Hi, I was wondering if anyone could help me with a DataTable problem. I am working in ASP.NET C#, The code that I have written is listed below. The moSqlDataReader can be viewed when in debug mode and the record that is asked for is seen, but when the reader is called into the DataTable using the .Load() function the DataReader shows a thrown exception of System.InvalidOperationException in the Depth and FieldCount properties when viewed in Debug mode
Code:
<br />
<small>msUserName = Request.QueryString.Get("username");<br />
<br />
LabelUserName.Text = msUserName;<br />
UserName.Value = msUserName;<br />
moMembershipUser = Membership.GetUser(msUserName);<br />
<br />
msEmailAddress = moMembershipUser.Email;<br />
<br />
moSqlConnection = new SqlConnection();<br />
moSqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AppSqlServer"].ConnectionString;<br />
<br />
moSqlCommand = new SqlCommand();<br />
moSqlCommand.CommandText = "SELECT * From tblUserInfo WHERE UserID = @UserID ";<br />
moSqlCommand.CommandType = CommandType.Text;<br />
moSqlCommand.Connection = moSqlConnection;<br />
<br />
moSqlParameterUser = new SqlParameter();<br />
moSqlParameterUser.ParameterName = "@UserID";<br />
moSqlParameterUser.SqlDbType = SqlDbType.UniqueIdentifier;<br />
moSqlParameterUser.Direction = ParameterDirection.Input;<br />
moSqlParameterUser.Value = new Guid(moMembershipUser.ProviderUserKey.ToString());<br />
<br />
moSqlCommand.Parameters.Add(moSqlParameterUser);<br />
moSqlCommand.Connection.Open();<br />
<br />
moSqlDataReader = moSqlCommand.ExecuteReader(CommandBehavior.CloseConnection);<br />
<br />
moDataTable = new DataTable();<br />
moDataTable.Load(moSqlDataReader);<br />
<br />
if (moDataTable.Rows.Count == 0){<br />
msFirstName = "";<br />
msLastName = "";<br />
}else{<br />
moDataTable.PrimaryKey = new DataColumn[] { moDataTable.Columns["UserID"] };<br />
msFirstName = moDataTable.Rows.Find("FirstName");<br />
msLastName = moDataTable.Rows.Find("LastName");<br />
}<br />
<br />
FirstName.Text = msFirstName;<br />
LastName.Text = msLastName;<br />
EmailAddress.Text = msEmailAddress;<br />
<br />
moDataTable.Dispose();<br />
moSqlCommand.Dispose();<br />
moSqlConnection.Dispose();</small>
I dont understand why the application is returning this, I have checked the internet and several books but have found no reason for this error. I would appreciate if anyone could help fix this.
Thanks
modified on Monday, April 14, 2008 9:44 AM
|
|
|
|