|
Hello,
I have the following code and I am not sure where I need to place it. I have three webpages Default.aspx, Add.aspx (this is the page used to submit information), and Confirm.aspx. Do I need to place it in a new class/business object or can I put it in the Add.aspx.cs page? I am using stored procedures ("InsertRequest") in this project. Also if the code is wrong somewhere please correct me. Thanks!
string connectionString = "Data Source = server02; Integrated Security=True; Initial Catalog=Database";
using SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("InsertRequest",
connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Summary",
txtSummary.Text));
command.Parameters.Add(new SqlParameter("@EmailAddress",
txtEmail.Text));
connection.Open();
command.ExecuteNonQuery();
}
}
|
|
|
|
|
I can't see any obvious problems with your code. As to whether it works, I suggest you try it and see what happens.
You can place the code anywhere you like - it will still work. The SOC[^] principle however recommends that presentation, business and data access logic should be physically separated in the codebase. Placing business or data access logic in your ASPX pages isn't a big issue on a small project where 1 developer is doing the work. For larger, multi-developer projects this approach soon becomes unmanageable, leading to code redundancy and maintenance problems.
To better understand the importance of SOC, I suggest you look at the new ASP.NET MVC[^] framework which is based around this principle.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
I've been investigating the MVC framework over the Easter weekend, and it looks like it could be a genuinely workable alternative to the traditional Web Forms model. Scott Guthrie's articles and the videos on the Microsoft ASP.NET site have been very useful. Form validation looked like it might be a problem, until I came across the MVC Validation Toolkit[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Scott's blogs are good, but as I point out, his examples are based on previous releases and won't work with the latest preview 2 release. The validator article look interesting. thanks
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: Scott's blogs are good, but as I point out, his examples are based on previous releases and won't work with the latest preview 2 release.
The principles set out in the articles still hold. You just have to work around the changes made to the framework between Previews 1 & 2.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: For larger, multi-developer projects this approach soon becomes unmanageable, leading to code redundancy and maintenance problems.
Yep thats exactly what I am going for something for a larger, multi-developer project. This project is starting out small but will definately be growing and I will need to setup this website where it can be managed well. Are there other alternates to the MVC framework? I might still go the route of Database (with stored procedures)-->Business Class-->Interface. Ideas/opinions/suggestions Thanks!
|
|
|
|
|
Programmer in the Making wrote: Are there other alternates to the MVC framework?
The ASP.NET MVC Framework is still in a preview release and probably isn't stable enough yet to consider building commercial applications with. However it's interesting to investigate and see where the technology is going.
Your best bet at the moment is create an ASP.NET Web Forms website with a 3-tier architecture[^]. The presentation, business logic and data access code would reside separate projects. Separating the different concerns makes it easier to manage the codebase as the application grows. It also means that you can create other presentation layers (mobile, Win32, WPF) that use the same business layer, or you can swap a SQL Server-based data access layer to an Oracle, MySQL one without having to rewrite your business or presentation logic.
You might want to look at using an ORM tool like SubSonic[^] to manage the creation of your data access layer.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I have a scenario in aspx page. when user click on Rates hyperlink, it should disply all the rates by countrywise. please click on below link. I have to implement like that in asp.net 2.0. when user click on A the page is coming to top and display all the list starting with A. if user click on H it should display countries starting with H.
Note: the data(country list) is coming from Database.
http://www.skype.com/prices/callrates/[^]
Thanks,
Chakri.
modified on Monday, March 24, 2008 10:05 AM
|
|
|
|
|
The letters of the alphabet are just a series of HTML bookmark anchor tags. The bookmarks are pure HTML and have nothing to do with ASP.NET. You can see how they work by examining the source of the page.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
ok. How to display the country list? list has to come from Database. is it possible to display in Datagrid? is there any other solution?
Thanks
|
|
|
|
|
Again, if you look at the HTML source for the page, you can see that there is a separate Table element for each letter of the alphabet. You could produce this output in ASP.NET using nested repeater controls[^]. The master repeater would render the header information for each letter, including the alphabet bookmark links. The child repeater would render out a table containing the price information for each letter.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi Everyone,
i need to convert the date formate,In my application day format is dd.mm.yyyy, i need to chanage mm/dd/yyyy.for using server side validation.
Please Help me, it's very urgent.
|
|
|
|
|
udaymohan wrote: Please Help me, it's very urgent.
Not another 'urgent' query
Putting this in your message pretty much guarantees it will be ignored. If it's so urgent, maybe you should pay someone to help you instead of asking on a forum where people answer questions for free.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi all,
when user click enter on the form the page is submitting . i d'nt want to submit the page while user click enter on the form .please give some soultion for this issue .
Thanks And Regards,
Guru
|
|
|
|
|
try with java script
window.event.keyCode
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
sorry yar it is not working for my case . the problem is whenever the user Edit the page i am doing All the fields are readonly and set tabindex property to -1; whenever he click enter on the form the button activate dfault .
Note:pls let me know if it is not clear to you.
Thanks And Regards,
Guru
|
|
|
|
|
AS per my understanding , you have one "Enter" button, and you want user should click on it !! not pressing Enter key !!!
am i clear ?
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
yes i have allow the user to click on the button then only it have submit . if he press enter key it can not be submit.
|
|
|
|
|
hi there,
how can i use master form in asp.Net 2.0, basically why i use this ???
any hint/samples ???
thankx in advance
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Have you heard of Google[^]? Or the MSDN[^] documentation? The answer to your question is easily available if you bother to look.
I suggest you read this article[^] to learn more about Google and what it can do for you.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I have an dll (Test.dll) thats been registered in GAC. I have an web site that has an reference of Test.csproj (rather than Test.dll GAC DLL file).
Firstly when I try compiling the web site I getting following message in the pop up box:
The following module was built either with optimizations enabled or without debug information:
C:\WINDOWS\assembly\GAC-MSIL\Test\1.0.0.0_4DB7AC663E1B5524\Test.dll
To debug this module, change its project build configuration to Debug mode. To suppress this message, disable the 'Warn if no user code on launch' debugger option.
Secondly inspite of the project reference, I am not able to debug the referenced Test.csproj project code.
Surprisingly when you refer a project over the GAC dll, you should be able to debug the referenced project code.
Do I require to perform any Visual Studio 2005 Debugging settings?
Regards,
Vipul Mehta
|
|
|
|
|
hi,
I'm working on making a Spanish version of my website and at the moment I'm trying to make a simple form where I'm giving an ImageButton on top with the Spanish flag so that one could get its spanish version on clicking it. I've made two resource files (index.aspx.resx and index.aspx.en-US.resx) Now I'm trying to change the resource file used by using the following code but its not working. It just doesnt give any outcome except for the same ol page in en-US.
Can any one plz tell me how to change the resx file used behind the scenes.
Thanks
<code>protected void ChangeLanguage_ImgButton(object s, EventArgs e)
{
CultureInfo culture_object;
culture_object = new CultureInfo("es-ES");
Session["culture"] = "es";
System.Threading.Thread.CurrentThread.CurrentCulture = culture_object;
System.Threading.Thread.CurrentThread.CurrentUICulture = culture_object;
}
</code>
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Typing Mistake
culture_object = new CultureInfo("es-ES");
Correct
culture_object = new CultureInfo("es-US");
change is ES to US
Best Regards,
Chetan Patel
|
|
|
|
|
I tried to use es-US but thats the exception:
System.ArgumentException: Culture name 'es-us' is not supported.
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|