|
|
Hi,I am following a sample project. but I don't understand some code of this program.Could you please help me. I put comment in front of lines.
Business Object Layer
[DataObjectFieldAttribute(true, true, false)] why use this line?
public int Id
{
get
{
return id;
}
set
{
id = value;
}
}
public string FirstName
{
get
{
return firstName;
}
set
{
firstName = value;
}
}
public string MiddleName
{
get
{
return middleName;
}
set
{
middleName = value;
}
}
public string LastName
{
get
{
return lastName;
}
set
{
lastName = value;
}
}
public DateTime DateOfBirth
{
get
{
return dateOfBirth;
}
set
{
dateOfBirth = value;
}
}
public PersonType Type
{
get
{
return type;
}
set
{
type = value;
}
}
public string FullName
{
get
{
string tempValue = firstName;
if (!String.IsNullOrEmpty(middleName))
{
tempValue += " " + middleName;
}
tempValue += " " + lastName;
return tempValue;
}
}
public AddressList Addresses
{
get
{
return addresses;
}
set
{
addresses = value;
}
}
public PhoneNumberList PhoneNumbers
{
get
{
return phoneNumbers;
}
set
{
phoneNumbers = value;
}
}
public EmailAddressList EmailAddresses
{
get
{
return emailAddresses;
}
set
{
emailAddresses = value;
}
}
#endregion
}
}
Business Logic Layer
[DataObjectMethod(DataObjectMethodType.Update, true)] why use this line?
public static int Save(ContactPerson myContactPerson)
{
using (TransactionScope myTransactionScope = new TransactionScope())
{
int contactPersonId = ContactPersonDB.Save(myContactPerson); why use this line?
foreach (Address myAddress in myContactPerson.Addresses) why use this line?
{
myAddress.ContactPersonId = contactPersonId; why use this line?
AddressDB.Save(myAddress); why use this line?
}
foreach (EmailAddress myEmailAddress in myContactPerson.EmailAddresses)
{
myEmailAddress.ContactPersonId = contactPersonId;
EmailAddressDB.Save(myEmailAddress);
}
foreach (PhoneNumber myPhoneNumber in myContactPerson.PhoneNumbers)
{
myPhoneNumber.ContactPersonId = contactPersonId;
PhoneNumberDB.Save(myPhoneNumber);
}
myContactPerson.Id = contactPersonId;
myTransactionScope.Complete();
return contactPersonId;
}
}
Data Access Layer
public static int Save(ContactPerson myContactPerson)
{
int result = 0;
using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
{
SqlCommand myCommand = new SqlCommand("sprocContactPersonInsertUpdateSingleItem", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
if (myContactPerson.Id == -1)
{
myCommand.Parameters.AddWithValue("@id", DBNull.Value);
}
else
{
myCommand.Parameters.AddWithValue("@id", myContactPerson.Id);
}
myCommand.Parameters.AddWithValue("@firstName", myContactPerson.FirstName);
myCommand.Parameters.AddWithValue("@lastName", myContactPerson.LastName);
if (String.IsNullOrEmpty(myContactPerson.MiddleName))
{
myCommand.Parameters.AddWithValue("@middleName", DBNull.Value);
}
else
{
myCommand.Parameters.AddWithValue("@middleName", myContactPerson.MiddleName);
}
myCommand.Parameters.AddWithValue("@dateOfBirth", myContactPerson.DateOfBirth);
myCommand.Parameters.AddWithValue("@contactpersonType", myContactPerson.Type);
DbParameter returnValue;
returnValue = myCommand.CreateParameter();
returnValue.Direction = ParameterDirection.ReturnValue;
myCommand.Parameters.Add(returnValue);
myConnection.Open();
myCommand.ExecuteNonQuery();
result = Convert.ToInt32(returnValue.Value);
myConnection.Close();
}
return result;
}
|
|
|
|
|
Rule 1: Don't post unnecessary code to ask simple question
Rule 2: Simple Goodgle search could have yielded tonnes of response
Rule 3: RTFD - MSDN Library[^]
|
|
|
|
|
I have seen many utilities and tools which promise to make my website best ranked in search engines...
what do you think? which one I should use for my ASP.NET website?
|
|
|
|
|
IMO, Using third party tools to make your site best ranked in search engine is not ethical. Instead of doing that, while developing your website, follow Search Engine Optimization guidelines. Then Automatically it'll come in search engine results.
|
|
|
|
|
jrahma wrote: I have seen many utilities and tools which promise to make my website best ranked in search engines...
what do you think? which one I should use for my ASP.NET website?
You need to read more about SEO[^]
and also check all Search engines are there own webmaster tools.
|
|
|
|
|
The two previous posters are spot on, read the optimization/webmaster guidelines for the search engines you are targeting. Sitemap XML generators are good, but beware of the backlink merchants: google has blacklisted some of these, if you are caught your ranking will go down.
|
|
|
|
|
Good Day all
i have a dummy javascript that can trap for enter key on the client side
function Enterkey()
{
var textb = document.getElementById("<%=TextBox1 %>");
if(window.event.keycode ==13 && textb.value.length > 1)
{
alert('Something will be Returned');
alert(textb.value.length);
}
return false;
}
and on my server side , i am trapping for textlength with something like this
if (TextBox1.Text.Length > 1)
{
}
elseif(TextBox1.Text.Length > 1 && "And the user Pressed Enter")
{
}
now look at the Elseif part, if the textbox is greater than and the user has pressed the return key(Enter) then it should execute the do whatever condition. i could do this on the client side , but my app requirement has changed so some of the code is on the server side.
how can i achieve this
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I don't think you can do what you are looking for because the server doesn't know what is going on at the client side until there is a PostBack. So, I think you need to implement this logic on the client side with Javascript.
Maybe there is something fancy that can be done with Ajax, but I'm no expert there.
My 2 cents.
|
|
|
|
|
Slap a hidden field on your form and have the javascript set the value. Then the server checks the value of the hidden field.
|
|
|
|
|
No, the server side can't intercept keyboard pressed events. What you can do is, use your javascript code to intercept it then pass it to the server using any of the postback events.
|
|
|
|
|
Hello,
I have a repeater with a label and a checkbox that bound to datatable.
I get three lines of labal+checkbox.
Now, after I click a submit button I want to check which one of the checkboxs is check.
The whole thing is inside a masterpage.
I don't know how to loop through the repeater rows and find the checkboxs.
Thanks.
|
|
|
|
|
The moment I post this I thought about the answer.
I'm looping with foreach on the items of the repeater and take the control in position 1 from the current item.
BUT - I have another problem now:
I getting id and description from the DB, I want to assign the ID to each checkBox so I will know which ID was check.
I didn't managed to do that in the repeater.
Thanks.
|
|
|
|
|
You might want to switch to a gridview and use the datakeynames property to keep track of the record ID for each row.
|
|
|
|
|
Hi All,
I want to create two virtual directories (lets call them as VD1 and VD2) poiniting to the same physical directory.
The only difference between the two virtual directories should be in terms of 'Impersonation'.
i.e. VD1 has impersonation = 'true' and VD2 has impersonation = 'false'
Is it possible to do configure this in IIS?
I tried the Impersonate option, but it also changes the web.config and I want to keep the same web.config for both the virtual directories.
Any help is appreciated.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
What version of IIS? What specifically are you trying to accomplish using impersonation? Who are you trying to impersonate, a local user, a domain user? Have you looked at using different application pools?
|
|
|
|
|
Hi Experts,
I don't know this is the correct Forum to post my message but it is related to ASP.NET.
We are going to migrate our application which is currently having Oracle 9i to Oracle 11.2. Do any one know what are the thigs needed to be done in the coding part in ASP.NET as we are using .NET FrameWork 2005. We are following 3tire architecture.
Thanks in Advance.
|
|
|
|
|
padmanabhan N wrote: .NET FrameWork 2005 I think it vs 2005
|
|
|
|
|
How are you accessing the data ?
ODBC, Native .NET libraries, 3rd party drivers ?
Check the release notes on your data access technology to see if there are any issues.
These guys have a good reputation for making good 3rd Party Dirvers
http://web.datadirect.com/products/net/net-for-oracle/index.html[^]
That is where the rubber hits the road.
In my experience with Oracle, you don't really have many problems with your application when you upgrade your Oracle version. (However, my experience was with Java J2EE and Oracle)
|
|
|
|
|
Hi, just wondering if anyone could recommend any good companies to host .NET sites with.
I need the all of the following:
Ability to host sites for at least 5 different domain names.
SQL Server hosting for at least 5 databases.
Ability to host MVC sites.
Silverlight support.
I am a bit stuck as I have never done this before and there seems to be a lot of options out there. I would also like the hosting to be as cheap as possible while still having all the things above.
Thanks
"What is best in life: Crush your enemies, see them driven before you, and to hear the lamentation of the women!"
|
|
|
|
|
Not sure if they'll cover everything but I use these 2 and they've both been very good.
SoftSys[^]
Discount Asp.Net[^]
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
You'll find hosting 5 separate SQL Server databases pretty expensive. Unless the clients are going to want direct access to them themselves, there is no reason why you shouldn't be able to place all 5 within the same database, as long as you're careful to ensure that your host doesn't tie you down to a separate database for each domain - there is no (technical) reason they should. (Not even sure they can, come to think of it - it's just a matter of what connection string you use.) Create your table names in a manner to make it easy for you to distinguish which table belongs to which application/client (add an appropriate suffix to each, for example) and create separate users with appropriate priveleges for each application too.
There, I've just saved you 80% on your database hosting costs! I'll take 10%
|
|
|
|
|
I mostly agree with using one DB and creating a different login/user for each client so that you can store all of your clients data in one DB, however consider this:
1) Backups - You may have to come up with a unique way of backing up a single client's data.
2) Performance - Each client will be sharing resources of the single DB, so you could get one client who "hogs" the DB and everyone suffers.
Just a thought.
|
|
|
|
|
Yes, but 1) is simple enough - you can backup (from) individual tables as easily as the whole database, and 2) well, I guess that depends on your clients, but unless one is pretty big (or gets a pretty impressive amount of hits or large data requests) they are unlikely to cause any noticeable difference to anyone else's response times. SQL Server can cope with (was designed to cope with) multiple users, and large amounts of data. And besides, unless you are going for a dedicated server (in which case this whole discussion is somewhat irrelevant) then you will be sharing your SQL Server instance with a lot of other users anyway, and it really won't make any difference whether you put all your data in one or more databases.
|
|
|
|
|
Thanks mate, sound advice!
"What is best in life: Crush your enemies, see them driven before you, and to hear the lamentation of the women!"
|
|
|
|