|
Time to learn something new this year.
So ASP.net MVC 4 Razor is the way to go?
I want to create responsive web designs from this point forward, done with the old stuff now.
Sure looks intimidating, I created the starter project, pretty neat how it creates the database for you.
Just wanted to get some feedback before I dive into this.
|
|
|
|
|
I would like to do as much as possible to tweak my existing web sites to a responsive design.
I guess this can be done via CSS, and a lot of brain work.
Or would it be better to just create a mobile version for small phones?
What are you guys doing with your classic web sites? and the small phone issue like the iPhone 4 or 5.
|
|
|
|
|
It's often not possible to "tweak" a non-responsive site into one that is, it normally requires a full UI and css redesign from the ground up. You should be able to keep your functionality and code, just change the markup.
If you do get a good responsive design then you can use the same site for mobile and desktop.
|
|
|
|
|
I started experimenting with the master pages of one of my web apps. Thought I did a great job with the CSS, until I got to testing on an IPad and Safari. So I sort of wasted a day of work, or saved a week.
I'm starting to think that perhaps just a mobile version using m.domainname.com would be a better solution, and just do device detection.
Perhaps this is a good reason to learn MVC, which is so foreign looking to me.
Your right on the money, it needs to be built from the ground up.
|
|
|
|
|
Asp.Net MVC is very neat. Initially it is hard to get around if you're from Asp.Net WebForms, but once you get a hang, you will never look back. In fact, you will hate WebForms.
For responsive design, you can use Twitter BootStrap[^] It is basically the ground framework for a good looking site, with built-in responsive design support. It will save you a lot of time and effort. There are many CSS frameworks on the web that support responsive design, a simple Google search should reveal them.
All in all, Asp.Net MVC is a great framework to invest in, and it is here to stay.
---
H.B.
|
|
|
|
|
I was just watching the training video on Code Project
Learn MVC (Model View Controller) step by step in 7 days – Day 1[^]
It makes sense to me now. MVC would be easier for me after the learning curve, and I can see how it would reduce my development time, and make projects more profitable, plus produce that responsive design I was looking for.
I looked at the Twitter Bootstrap website, will download a copy and see if that's a good start point for me, and figure how to merge that in.
Thanks for the positive feedback on my choice to move forward this year, and the pointers!
I'm going to have a thousand questions here. like how to place an image element in the view.
|
|
|
|
|
Sure thing! If you have any question, feel free to ask, me and many other members are willing to help. Google also has an abundance of questions and answers.
Just to give you a little perception on the view:
Your controller will pass in a "model" to the View. The model can be your domain object, or a view model. I don't want to go into too many details and make it more confusing. You will learn these things as you get more into Asp.Net Mvc.
The view is a template with all the html and razor code. A sample template will be like this:
<!--
<h1>@Model.Name</h1>
<img src="@Model.ImageUrl" />
The razor templating engine then parses the HTML, fills in the model properties from the controller, and renders the raw HTML in the browser. Asp.MVC does all that automatically on the backend.
This produces clean and concise HTML, and lets you make it as semantic as you like.
It is all very beautiful.
H.B.
|
|
|
|
|
Cool, I was going to ask if I should use razor.
Installing that VS2013 Community Edition right now, and will start again today.
I've always had regrets about adopting asp.net webforms versions, so much of it was just stupid.
Was considering that Ruby on Rails or just going back to PHP and Linux, but I see a lot of PHP sites that I frequent using MVC now. I think Best Buy is now MVC as well.
|
|
|
|
|
MVC4 is actually quite old now. MVC 5.2.2 is the most recent version, and MVC6 is in development (for release later this year). You can download the free Community Edition of Visual Studio 2013 for personal use to learn MVC 5.x, or you can download the Visual Studio 2015 CTP if you want to get a head start on MVC6.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
My action pack or MSDN subscription expired for VS2013, I'll try the community version and give 5 a spin.
I was just working on MVC 4 just now, watching the Code Project Article "learn in 7 days"
So I guess I will dive into this this week, and build my website in it first.
Thanks for the version info, I didn't know about that.
Learn MVC (Model View Controller) step by step in 7 days – Day 1[^]
|
|
|
|
|
Any one have dll and source code for this
to convert .vox file format to mp3 format.
I am working wthi Alvas.Audio but its not working
and its also asking for License.
Plz Help...
|
|
|
|
|
Does this have anything to do with ASP.NET? If not I suggest you try the Alvas.Audio website, and also use properly licenced software.
|
|
|
|
|
Thanks
Richard MacCutchan
|
|
|
|
|
Am having the following code to find the Number of Alphabets and Number of Numeric characters from a string contains alpha numeric characters.
Public Sub CountAlphaNumeric(ByVal input As String)
Dim alphaCount = input.Count(Function(c) Char.IsLetter(c))
Dim numericCount = input.Count(Function(c) Char.IsDigit(c))
MessageBox.Show(String.Format("Number of alphabets : {0}", alphaCount))
MessageBox.Show(String.Format("Number of numerics : {0}", numericCount))
End Sub
Is their any alternate method are available? I think it is the simplest.
sujith karivelil
|
|
|
|
|
That is Linq at work, what is your question?
|
|
|
|
|
He is probably looking for alternate method.
May be, simple for /foreach loop.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
I need download forum plugin in C# asp.net and how can i add plugin in asp.net
|
|
|
|
|
You should search in tutorial website instead of asking it in forum.
We can't help unless you have a pin point question.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
What is your question? It is not clear.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am trying to develop a contact form with a simple html and css but now I have to do the file asp not know how to do and do not know where to start. Can you help me out?
sorry for my bad English
http://jsfiddle.net/yt95fj0q/[^]
|
|
|
|
|
I've outsourced my enterprise level project to a freelancer and I got a quite good setup too. But now that contract has finished and the person has also moved to a new technology, in other words not willing to extend the contract. Now I'm looking into this code on myself. I do have a 2 3 years of background in C# and MVC. Below is a rough idea of my application architecture. Hopefully I've tried my best to abstract the architectural details of an enterprise level application. Please let me know if you need further brief on any of the questions.
All my Entities are defined as C# POCO classes as:
public class Product : BaseEntity
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}
Now I've a IDbContext like as :
public interface IDbContext : IDisposable
{
IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity;
}
Base Entity is a Partial POCO class that each POCO entity is inheriting. Here is a class that implements this IDBContext as:
public class MyObjectContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
{
return base.Set<TEntity>();
}
}
Now I've defined a IDbContextFactory that is responsible for providing the DBContexts as :
public interface IDbContextFactory
{
Lazy<IDbContext> CreateDbContext();
}
The class implementing this IDBContextFactory interface is having below structure :
public class MyDbContextFactory : IDbContextFactory
{
public MyDbContextFactory(string dbConnectionString)
{
_dbConnectionString = Settings.DbConnectionString;
_dbContext = CreateDbContext();
}
public IDbContext CreateDbContext()
{
IDbContext dbContext = new IDbContext(() => CreateNewContext());
return dbContext;
}
private MyObjectContext CreateNewContext()
{
return new MyObjectContext (_dbConnectionString);
}
}
Here IRepo Pattern comes into role as:
public partial interface IRepository<T> where T : BaseEntity
{
T GetById(object id);
}
Now the Repository class implementing this Interface is as below :
public partial class EfRepository<T> : IRepository<T> where T : BaseEntity
{
private readonly Lazy<IDbContext> _dbContext;
private readonly IDbContextFactory _dbContextFactory;
private readonly Lazy<ObjectStateManager> _objectStateManager;
public EfRepository(IDbContextFactory dbContextFactory)
{
_dbContextFactory = dbContextFactory;
_dbContext= _dbContextFactory.CreateDbContext();
_objectStateManager= new Lazy<ObjectStateManager>(() => ((IObjectContextAdapter)_dbContext.Value).ObjectContext.ObjectStateManager);
}
public T GetById(object id)
{
return this.Entities.Find(id);
}
}
Till now we are done with the Infrastructure level setup for DB Access Management. Now the thing is to utilize this setup into Controllers(as I'm having directly accessing Repositories from Controllers) to as below :
public CountryController(Lazy<IRepository<Country>> countryRepository)
{
_countryRepository = countryRepository;
}
public Country GetCountryById(int id)
{
Country country = _countryRepository.Value.GetById(id);
if (country != null)
return country;
else
return null;
}
Hopefully all above is clear. Now here are the some questions that I need to be answered :
1) Why we are having this layered flow like as:
IDBContext -> IDBContextFactory -> IRepository <T>
and then finally using this IRepository into Controllers for accessing Data objects. In other words why we are relying on Interfaces instead of actual Class Objects while implementing Constructor Injection for Country Controller ?
2) Is this the correct approach for a Enterprise level Application as it should be much scalable for future purpose. If there is any other then I would be glad to know about that ?
3) In Controller's constructor I've used Lazy>, so what's the purpose of this Lazy and is it beneficial actually If yes then in what way ?
modified 29-Jan-15 7:16am.
|
|
|
|
|
|
Interfaces are used over concrete classes mainly to allow dependency injection and also better unit testing. If your code has neither of these then interfaces might have been used anyway so that if you do use DI or unit testing in the future then you don't have to re-factor all of your code.
|
|
|
|
|
While it's true that interfaces are useful for these purposes, that's not why they exist or why they are mainly used.
Interface Segregation Principle is one of the Five principles of SOLID design, and stands on its own beyond its use in testing or DI. Interfaces are used to decouple implementation from contract and are important in many other patterns and practices.
Do not fall into the trap of thinking they are only useful for testing or DI, and they don't need to be used otherwise.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Yes I know what they are used for thank you very much. I was trying to give a real-world answer to the real-world question that was posted. The question wasn't "Why should I use an interface" so my answer was not addressing interfaces in general. I didn't say they are only used for DI and unit testing and that they don't need to be used elsewhere.
|
|
|
|