How to Reduce the File Size of Videos in Various Ways
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you
How to Reduce the File Size of Videos in Various Ways. Videos are known to have large file sizes that can range into several gigabytes. The longer the video and the higher its quality, the larger its file size tends to be.
The fact that videos are so large can pose a lot of problems. Not only will they take up more storage space, but transferring them can present more of a challenge as well. That is why it can be helpful to know how to reduce the file size of your videos, in a number of different ways.
How to Reduce the File Size of Videos in Various Ways
Let's have a look at How to Reduce the File Size of Videos in Various Ways. All these ways are mentioned below in detail:
Transcoding the video codec
Most videos are already compressed in some fashion, but not all video codecs are equal when it comes to the efficiency of their compression. In general newer codecs are able to compress video data more effectively, and so you may want to transcode to one with better compression.
The only caveat is that newer codecs aren’t as widely supported, so you will need to check that the device or platform your video is to be played on does support it.
At very least you should transcode videos to H.264 as it is almost universally supported. If it is an option you can transcode to
H.265 (HEVC) to reduce the file size even more, but it is not nearly as widely supported. The main advantage of this option is that you will be able to reduce the file size of your videos without affecting their quality.
Adjusting the video bitrate
By definition the video bitrate is the amount of data that the video can use each second. That directly affects the file size, which is essentially the video bitrate multiplied by its duration. Lowering the video bitrate will let you reduce the file size of the videos as much as you want. However it will affect the video quality as well, and
compression artifacts will appear if you lower the bitrate too much.
The optimal bitrate for videos depends on several factors, such as the video codec, resolution, and frame rate.
Extracting short clips from videos
As you can imagine this option won’t reduce the size of the overall video – but it will let you end up with a smaller-sized video. It is only useful in situations where you are interested in small parts from much longer videos.
By extracting short clips from your videos and saving them separately, you will end up with videos that have significantly smaller file sizes. The exact difference will depend on the length of the clips you’re extracting compared to the length of the original video.
Keep in mind that none of the options listed above are mutually exclusive, and you can use them in combination with one another if necessary. For example you could convert a H.264 video in
MKV to MP4 with H.265 (HEVC) using Movavi Video Converter, then reduce the bitrate, and extract the clips that you want from your video.
As you can see the exact options you’ll want to use will depend on your specific circumstances. It is ‘best’ to transcode the video without affecting its quality – though that may not always be an option that is available to you. If it isn’t (or if you need to reduce the file size further), reducing the bitrate or extracting short clips are your best bets.
Best Data Recovery Software for Emergency Cases
Hello friends, I hope you all are doing great. In today's tutorial, we will discuss about Best Data Recovery Software for Emergency Cases. Do you know this nasty feeling when you need an important file and it is just not there? Or what about realizing that the huge block of data that you need so badly has been deleted just a couple of hours ago? That’s a feeling you can never forget even though you would like to.
Don’t worry though. There are solutions for everything, and the offer is always there where the demand is. There are plenty of special tools used for files recovery.
You might object that not all of them are efficient enough, and you are absolutely right. Some tools can recover only a limited volume of data. Others work only if the files disappeared from a PC, but not from connected devices, and so on. So, now you are selecting one of the best data recovery tools. What about checkingÂ
Disk Drill then? It might be the solution you are looking for.
A Tool That Takes Care of Your Data
If you have deleted a file accidentally, it is an emergency. If the file was stored in an external disc, the situation would be lost with many other tools. However, Disk Drill, the best free data recovery software for Windows, is different. It restores files from everywhere. If you have deleted them from your PC or any other external device, just run the tool. It will recover whatever is still possible to recover.
You might be wondering why it is the best professional data recovery software for Windows. Then, just a quick question: what would you do if your files were damaged by a virus? Or if they disappeared due to a computer failure? Do you know any free recovery tool that would handle this unpleasant situation for you? This best data recovery software for PC does it. It recovers files just from everywhere, even if they were lost in any circumstances.
The tool works perfectly if the data has been lost recently. But if that happened a while ago, Disk Drill might need more time. Not everybody can sit in front of a lap waiting until the files are back. But that’s why we are talking about the best data recovery software. The process can be paused, stopped, resumed whenever you need it. So, you can start the process, then pause it, and resume it again when you want.
Paid Versions Offer More Opportunities
Now, you might be wondering why one would pay for a Premium Version if such opportunities are available for free. Well, as you can guess, there are some limitations:
- You can recover up to 500 MB for free
- Partition search is available only with paid versions
- Reconstruction of more than 300 file formats
For an individual use, a free version is probably more than enough. But if you run a business or if your work is connected with data, then a paid version would ensure for you the highest safety level of your data.
How to Power a Micro Linear Actuator
Hello friends, I hope you all are doing great. In today's tutorial, we will have a look at
How to Power a Micro Linear Actuator. Before powering your micro linear actuator, make sure to pick the most quality option that fits your particular goals best.
The four most important features your actuator of choice must have are technical features and capabilities like: pushing/retraction power, operating cycle, speed, load factor, and others. Check these and the following features as well in the manual that comes with your actuator.
How to Power a Micro Linear Actuator
- Operating features like temperature limits, sensors necessity etc.
- Price.
- Accessibility.
And don't forget about actuators' optimization. It is very important as well.
So, after you've picked and got your micro linear actuator delivered, it is a high-time to power it up.
Powering
linear electric actuators is pretty much easy and it usually doesn't depend on what exact type of actuator you have. Most DC- and AC-type actuators operate from the power supply and a DPDT (Double Plie, Double Throw) switch.
Make sure you get a switching power supply that has a 12V output cable of a 6A. With this, you are able to work and operate all of your struts at the same time. And those struts can be under the full load. Make sure you know how many struts you need to operate at once. If it is only one strut, then you'll be fine with a 3A supply. And you should know how much force is being pushed unto each one of your struts. Because the amount of the current drawn depends on that force.
Try to wire them concurrently. It is the easiest way. But there is a possibility that they won’t work synchronously. You need to make sure that they are bolted together. In case if they are misaligned, there is a high possibility that the thing you mount the actuator to will break. Or just make separate switches for each strut. With that, you will be able to control each actuator separately.
Here is the part where you can find out how to change the direction of the current via reversing the polarity. The easiest and the only thing to do is to use a DPDT switch or a relay.
The scheme for wiring with a DPDT switch looks like this:
And the scheme for wiring with a relay looks like this:
When you buy switches, check that they are rated at least 3A (works well with one strut) or 6A (works well with two struts). Both of these switches can control the electrical current. If you go and get smaller or cheaper switches just know that they actuate the coils of bigger (10A) relays. And those are the subjects to the reversing and enabling the power.
If you are attaching the actuator to your desk that has only one single strut which is in the middle, think about adding some additional stabilizing details at both sides of this table. You can add arms, or scissors, or anything else you might find interesting or handy. And with that, you have a possibility to get rid of alignment issues. And no additional synchronization is required if everything is done right. If you are planning to lift something that weighs more than 150 kg, consider adding another strut. This will enable the support of up to 300 kg on your desk. How cool is that? Btw you can also automate it by interfacing any Microcontroller like Arduino Nano etc.
Conclusion
There is nothing scary or difficult in powering a micro linear actuator. There are some schemes that you might find useful for your case. Remember that everything you do is an art, so building something with a dash of engineering makes it even cooler.
Good luck with actuators!
Robotic Tailoring is The Future of Fashion (sewing machine)
Technology has advanced a lot in the last century with robots doing almost everything, from cooking to even sewing. They are able to sew materials, even if it seems like a complicated process, making them now an important part in the fashion, as we know it.
Automation came for every industry, and fashion is not going to be left out; it is changing the minds of everyone involved from manufacturers, retailers, to stylists and designers. The robots are already here and various brands are using them in their process of creating trendy clothes, making every aspect of the industry automated or improved by tech.
For years, we have been helped by robots that are able to cut through anything, but when it comes to sewing, as it required in fashion, is a process a lot more complicated that takes time to perfect.
Tech will evolve in the future and smarter robots are going to take over every industry. In some fields, automation has already surpassed expectations. For example, there are robotic pool cleaners that eliminate the need for workers to tend to clean the pools as the devices already deliver perfection. The latest robots are able to clean all the surfaces of a pool while maintaining a high energy efficiency to help save costs, and who knows what else the future holds.
Seeing how profitable it is to replace people with robots, some companies
are even launching robots capable of sewing by combining software and hardware in one process. Brands are already using some of the most popular 3D tech or even the latest sewing robots.
While some brands plan to bring their production closer to their office, others are using 3D technology to give people customized goods only available by order as well as opening new horizons for easy customization.
CHANGING THE BUSINESS
Electric sewing machines have been around since the WW2, but they could only work with the help of a human being. Nowadays, the automatic revolution has begun reducing the number of workers needed for mass production of clothing to more than a half.
Robots are built with sewing and cutting the fabric features.
AI is already affecting the big brands into making smarter decisions about their products, turning the next era of fashion into an era that is about their way of predicting and customizing their goods.
Large fashion companies
are using technology to understand their customer’s needs, a factor that is growing their profits, allowing them to predict what customers will want to wear not so far in the future, as we anticipated before.
When the
sewbots evolved, they took over many tasks performed by humans leaving them without their jobs and main income. While the fashion industry evolves, the
humans must search for other places to work that have not yet been taken over by robots.
On the other hand, with robots replacing the sewing machines, the
productivity has increased making some companies able to supply their merchandise to their customers quicker.
It’s not to say that it has become futile for the fashion industry yet, but the truth of the matter is that everyone seeks efficiency, especially when discussing business. The heavy duty sewing machine is irreplaceable for fashion from many points of view as it withstands intense use and
delivers the speed this industry needs, being able to sew at a moment’s notice. It needs to be operated by a person who can work for a limited number of hours per day, however, and who might even make mistakes. This isn’t an issue to be had if the process is conducted through robotic tech as human error and needs are taken out of the equation, which results in higher profits for business owners and increased production.
The rise of the robotic tailoring has made popular seasons almost disappear from the industry, another detail worth mentioning, and now
more brands are announcing micro-seasons instead of the old seasons. To keep up with the advanced tech brands, the traditional ones began releasing more and more and created their own seasons
.
BENEFITS
Besides making the process of creating clothes quicker, the using of robots in the clothes business has other benefits.
This robotic industry will help many companies go back to where they started, which will eliminate the need for skilled labor, a short supply there and too costly for most of their customers.
It will
not produce many factory jobs but would generate more
jobs in the administrative and managerial level. Overall,
robots in the fashion business may have a positive outcome, but it can have a negative impact as well. It can allow us to take overseas jobs, for example, and cheaper clothes, but the impact on the economy of developing countries could be catastrophic.
THE DOWNSIDE BUSINESS
The dark side of this new environment is caused by the low-cost, low-quality clothes in workshops with uncertain working conditions, with low-paid workers. Moreover, the cheap fabrics used to make inexpensive clothes are treated with bad chemicals.
The fast fabrication generates massive textile waste, which damages the workers and the surroundings. According to EPA,
around 13 million tons of clothes are disposed of every year.
Some of the robots created only work on a specific type of material, a challenge for manufacturers in the beginning, but now they found
a way to manipulate the materials, to make them compatible. To this option are of course some limitations, because materials need to be completely wet, and certain fabrics are to be used, but overall, the process is doable.
We are almost sure that they will not take over the world and make us their slaves, so do not worry about that.
Let us not forget that the making of a robot could take months, only making the water-soluble thermoplastic to stiffen fabric to be like cardboard takes a lot of time. However, when it comes to stitching together complicated patterns, human hands are still the best option rather than those inflexible robot hands.
Create Promotional Videos Like a Pro
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you How to Create Promotional Videos Like a Pro. Creating a promotional video is one of the major factors for dominating online traffic. It is the most powerful part of your content. According to a prediction, in the next few years, most of the part on the World Wide Web will be taken over by the videos.
Cisco estimates that video traffic will contribute 82% of the global internet traffic by 2021. Undoubtedly, this number is only going to rise up. It is because videos are capturing and keeping the attention of people more than text-based content.
If you are seeking to create a promotional video for your business like a pro and don’t know from where to start, start reading about popular video marketing tools. These tools are efficient and help you create a video in a few minutes.
How to create promotional videos like a pro?
Today, you can read several blogs that illustrate how to create promotional videos for your brand. Websites like the Engineering Projects has a forum where people discuss the topics and posts about creating videos and many other topics. Coming to the main topic, how to create a promotional video like a pro, so let’s find out…
1. Identify Your Objective
Before planning to sit down to script your video, take a step back and think why you want to create a video? Undoubtedly, videos can be expensive to create, so it is crucial to identify your objectives first. For instance, you’ve started a new company and you want to create a video that introduces the mission of your brand to the visitors. Or you have a new product line that needs to be explained to prospective buyers. Or you are running a sale and require people to take action. Usually, a video helps the brand in driving sales, traffic, educate customers and increase customer engagement.
2. Select A Direction
Now that you have identified your objective, it is time to choose a direction for your video. A video can help you introduce your business motive, encourage visitors to take actions, give solutions, and more. There are several possible directions including introductory, informative, drive action, explanatory, entertainment,  problem/solution, narrative, testimonials, and more to pick from. Once you’ve finalized your video objective and direction, it is time to further refine your video making approach by writing a script.
3. Write a Script
A well-written script is a base for an effective brand video. So ensure to take out some time and write down a valid script before starting to make a video. Your script should be able to:
- Grab the attention of your viewers
- Describe what your brand does (in an easy-to-understand method)
- Keep your viewers engaged
- Boost your conversion rate
Also, the sentences that you use in your video should be simple, short, and concise so that viewers can understand your motive. Speak in a personal tone and end things with a call to action.
Another important thing you should mention in your script is - the duration of your video. Keep the length short as much as possible. The reports show that
people tend to drop off after the first 30 seconds, so keep your video to a minute or less.
4. Use an Online Tool
If you are ready with your marketing strategy (your objective, target audience, and brand goal), the next step is to start making a video. The best way to create a brand video is to take help from a reliable
video making tool.
There are several tools available that can help you create professional brand videos in the cloud in a couple of clicks. From different options available to select from, you can pick Renderforest to make your dream come true. Choose a professionally crafted template as per your project theme, edit it, and put your brand in the spotlight in minutes. Using this tool, you can create a short or long video with lasting impact and can promote your brand with style.
Conclusion
These are some crucial tips you must follow to create promotional videos like a pro. Plan well, strategize and implement your idea to create great promo videos to take your brand to the peaks of success. Videos have the power to change the perspectives of your viewers. So, plan wisely to create a captivating video and present your business in the positive light.
Being a startup in this industry, first of all, you need to make your business website. If you’re not a designer, it would be perfect to consult an expert regarding your list of important and final website making details.
Browse websites like
TEP (The Engineering Projects) that can help you design attractive and SEO friendly website at a minimal cost with complete control on iPhone, Blackberry, and Android apps.
Once you’ve made your business website, you may proceed with producing professional videos for your brand. Keep all aforementioned tips in mind, begin creating stunning & exciting professional videos, and start your brand promotion.
Bio: Roman Daneghyan is Chief Marketing Officer at Renderforest, specializing in social media marketing, content marketing, and SEO.
NuGet Package Management in ASP.NET MVC
Hello friends, I hope you all are doing great and having fun with your lives. In today's tutorial, we will discuss in detail about NuGet Package Management in ASP.NET MVC. It's 15th tutorial in ASP.NET MVC series. Today's tutorial is not about programming, instead we are gonna discuss this pre installed tool NuGet Package Management in ASP.NET MVC.
NuGet Package Management is use to install packages and libraries, which you want to use in your project. It downloads the files online and then installs it. So, let's discuss this ASP.NET MVC tool in detail:
NuGet Package Management in ASP.NET MVC
- NuGet Package Management is a package manager for ASP.NET MVC, which is used for downloading and installing different packages & Libraries online.
- If any of your packages needs to be updated, then it can also be done by NuGet Package Management.
- There are many third part packages available online, even there are many independent packages developed by Microsoft itself, which you can easily download & install using NuGet Package.
- These third party packages could be open source or closed source.
- So, now let's have a look at How to install any package using NuGet Package Management in ASP.NET MVC.
- Right Click on your Projects' name in Solution Explorer and then click on Manage NuGet Packages, as shown in below figure:
- It will open up a NuGet window in your workspace, as shown in below figure:
- You can see in above figure that NuGet window is opened and it has three tabs:
- Browse: For browsing new packages.
- Installed: Search pre-installed packages in your visual studio.
- Updates: Here you will get the notifications for updates of your pre-installed packages.
- On the right side of each package, we have two versions listed.
- The upper version is the installed version of that package in your visual studio software and the lower one is currently available version.
- You can click on the upper arrow to update that package.
- Here's the video demonstration of NuGet Package Management in ASP.NET MVC:
So, that was all about NuGet Package Management in ASP.NET MVC. It was a quick tutorial as I don't have much to explain here, its a simple tool but you should know about it as it will be used in coming tutorial. That's why I have posted it. If you have any questions, please ask in comments and I will try my best to help you out. Thanks for reading, have a good day. Take care !!! :)
Validation in ASP.NET MVC
Hello friends, I hope you all are doing great. In today's tutorial, we will discuss
Validation in ASP.NET MVC. It's our 14th tutorial in ASP.NET MVC series. In our previous tutorial, we have seen
Model Binding in ASP.NET MVC and you have seen we have created a View for our Model class.
In today's tutorial, we are gonna add some validations on the data provided by the users in those Text box fields. We will place some constraints like the age must be above 13 or the characters of name must be between 4 to 20. So, let's have a look at How to deal with Validation in ASP.NET MVC:
Validation in ASP.NET MVC
- Validation uses built-in attribute of ASP.NET called DataAnnotations and is used to validate inputs provided by the user.
- Validation is a very powerful attribute of ASP.NET MVC and it can be applied to entire model class or any property of model class.
- It places a restriction on the inputted data by the user, and if the data doesn't follow the specified rules then it will generate an Error Message and won't allow the user to submit form.
- It's really helpful from development point of view, as the developer always gets the data in single specified format, thus can easily handle it.
- Following table shows few of the most commonly used Validations in ASP.NET MVC:
Validation in ASP.NET MVC |
No. |
Attribute |
Description |
1 |
Range |
Value sould lie b/w specified range (e.g. Age) |
2 |
StringLength |
Maximum Characters (e.g. First Name) |
3 |
Required |
This field is Compulsory. (*required) |
4 |
RegularExpression |
The user input must match the provided format (e.g. Date / Time) |
5 |
MaxLength |
Sets the Maximum Limit. |
6 |
CreditCard |
For Credit Card details. |
7 |
CustomValidation |
Custom validations defined by developer. |
8 |
FileExtension |
Restriction on File Extension (e.g. only img file) |
9 |
MinLength |
Sets the Minimum Limit. |
10 |
EmailAddress |
Email Address must be provided. |
11 |
Phone |
Phone Number Format must followed. |
- I hope you have now got the basic idea of what is validation.
- Now let's implement one of these validations in ASP.NET MVC.
- So, open your StudentModel.cs file, it's our model class which we have created in tutorial: How to Create a New Model in ASP.NET MVC.
- You can see in the above figure that I have added an attribute before Name variable.
- It's a StringLength Validation and the first parameter which I have set to 20 is the maximum length of string allowed.
- While minimum length is specified as 4, so this Validation is restricting the Name model to only accept value of length between 4 and 20.
- So, now run your application and check the View and in Name Text box enter your name, here are the results:
- In Case 1, the input string length is less than 4, while in Case 2, length is greater than 20.
- That's why it has given error in both cases.
- We can also add multiple Validation to single property, as shown in below figure:
- Below this StringLength, I have placed another Validation in ASP.NET MVC which is [Required].
- So, now it will also make sure that Name field is not empty.
- Here's the video demonstration of Validation in ASP.NET MVC, have a look at it:
So, that was all about Validation in ASP.NET MVC. I hope you have enjoyed today's tutorial and I would suggest you to try all those Validation as a homework and share your codes with us in the comments. Thanks for reading, Take care !!!
Model Binding in ASP.NET MVC
Hello friends,I hope you all are doing great and having fun with your lives. In today's tutorial, we are gonna have a look at
Model Binding in ASP.NET MVC. It's our 13th tutorial in ASP.NET MVC series. Today, we are gonna discuss a new concept in ASP.NET MVC and it's more of a luxury as it automates the job and makes our work easy.
Suppose, in your application, you want to create a registration form and thus you need to pass this data from View to your model, so that it could be saved in your database. So, in order to bind this HTTP request data from View to Model, we use Model Binding. Let's have a look at Model Binding in ASP.NET MVC in detail:
Model Binding in ASP.NET MVC
- Model Binding in ASP.NET MVC is used to bind the data sent by the HTTP request with Model.
- You must have viewed during some form submission online, that when you click on the submit button then a form of data is sent by the HTTP string.
- This HTTP data is linked to the Controller's action methods in the form of input parameters.
- For example, suppose we have an action method "public ActionResult Edit(int id)", here the parameter int id could be used as a model binder.
- It may happen that this id value is coming from some HTTP request "http://localhost/Student/Create?id=10".
- So, the model binders get data from View via HTTP request and then pass this value to Controller's action method, which in turn shows up to models.
- When we create a new form in ASP.NET MVC, then this model binding is automatically done by visual studio.
- Let's create a new View and have a look at working of Model Binding in ASP.NET MVC.
- So, in your StudentController.cs file, right click on the action method Create and then click on Add View, as shown in below figure:
- When you click on the Add View, it will open a New Window for Creating a View.
- We have already seen it in How to Create a New View in ASP.NET MVC.
- So, here's the screenshot for the settings, first I have given this View a name Create, then I have selected Create Template.
- Finally, I have selected the Model class, which we have created in one of our previous tutorial: Create a New Model in ASP.NET MVC.
- After these settings, click the Add Button and a new View for the Create action method will be created.
- Create.cshtml file will open up in your workspace, as shown in below figure:
- If you remember the Student Model, it has four variables as shown in below figure:
- So, let's open our newly created Model in the browser.
- If everything goes fine then you will get similar results:
- You can see in the above figure that visual studio has created the same four fields in the View which were present in the Model class.
- The data we will enter here will be sent to the model and then will be saved in the database.
- Code for the Model Binding in ASP.ENT MVC has automatically been created, which we have seen in Create.cshtml.
- Here's the video demonstration of Model Binding in ASP.NET MVC:
So, that was all about Model Binding in ASP.NET MVC. If you got into any trouble in understanding it, then ask in comments. In the next tuorial, we will have a look at Data Validation in ASP.NET MVC. Thanks for reading, Take Care !!! :)
HTML Helpers in ASP.NET MVC
Hello friends, I hope you all are doing great. In today's tutorial, we are gonna have a look at
HTML Helpers in ASP.NET MVC. It's our 12th tutorial in ASP.NET MVC series. I know every tutorial is a new concept for you to understand but we have to cover all of them before starting working on our project in ASP.NET MVC.
If you have worked on ASP.NET web forms or C# / Visual Basic projects then you must be aware of toolboxes, from where we can drag and drop our visual components like textbox, editbox, button etc. But in ASP.NET MVC applications, we don't have this luxury of drag and drop. Instead we have HTML Helper classes which are used to created these html components in ASP.NET MVC. So, let's have a look at How to use HTML Helpers in ASP.NET MVC:
HTML Helpers in ASP.NET MVC
- HTML Helpers are simple C# classes in ASP.NET MVC, which are used to create HTML components in the run time environment.
- HTML Helper creates a path for displaying model values (saved in SQL Databases) in respective HTML components e.g displaying name in Name Text Box.
- We can also get values from HTML components and then save them in our database via Model. You should recall Tut # 02: What is a Model ?.
- So, instead of drag and drop as in C# applications, in ASP.NET MVC we are generating and controlling our HTML components programmatically using HTML Helper classes.
- There are numerous HTML Helpers are available in ASP.NET MVC but the most commonly used HTML Helpers are shown in below table:
HTML Helpers in ASP.NET MVC |
Type |
Forced Type |
Description |
Html.TextBox |
Html.TextBoxFor |
It creates a Text Box. |
Html.TextArea |
Html.TextAreaFor |
It creates a Text Area. |
Html.CheckBox |
Html.CheckBoxFor |
It creates a Check Box. |
Html.RadioButton |
Html.RadioButtonFor |
Radio buttons are created using this HTML Helper. |
Html.DropDownList |
Html.DropDownListFor |
Drop Down List is created with it. |
Html.ListBox |
Html.ListBoxFor |
It is used to create Multi-select list box. |
Html.Hidden |
Html.HiddenFor |
Hidden fields are created with it. |
Password |
Html.PasswordFor |
Password text box are created with it. |
Html.Display |
Html.DisplayFor |
It creates Html text. |
Html.Label |
Html.LabelFor |
Labels are created here. |
Html.Editor |
Html.EditorFor |
Editor is created using it. |
Html.ActionLink |
|
It creates Anchor link. |
- In normal HTML language, we use html tags e.g. <a> this html tag is used for linking, but in ASP.NET MVC we use HTML Helper and HTML Helper makes it too easy to bind model data with View design.
- For example, if we are working on simple html then we will use
<a href="/Student/Click ME">Click ME</a>
this code to create a link, but in HTML Helper it will be @Html.ActionLink("Click ME", "Click ME")
.
- I have simply used Action Link, which will create a Link component and then I have given it a name and then action method.
- So, when you click on it then Click ME action method will be called.
- Open the index.cshtml file of our Student Controller. ( Recall: Tut # 6: Create a New Controller in ASP.NET MVC )
- I have removed the extra code in this index file and have added a new HTML Link Helper, as shown in below figure:
- You can see in above figure that Link Helper has two inputs, the first one is the Anchor Text of the Link, while the second one is the action method which should be called i.e. Get1().
- Here's the video demonstration of HTML Helpers in ASP.NET MVC:
So, that was all about HTML Helpers. You must have got the idea that Html Helpers are not that difficult, in fact they are here to ease the job. Thanks for reading. Take care & have fun !!! :)
Action Selectors in ASP.NET MVC
Hello friends, I hope you all are having fun with your lives. In today's tutorial, we are gonna have a look at Action Selectors in ASP.NET MVC. It's the 11th tutorial in ASP.NET MVC series and if you have covered so far then that means you really want to learn this language. Action Selectors are also new for you as we haven't discussed them yet but they are not that difficult to understand.
Action Selectors are built-in attributes of ASP.NET which are directly applied to action methods of Controllers. We use Action Selectors to influence on Controller's action methods. In simple words, we use Action Selectors to guide URL Routers in selection of correct action method. Let's have a detailed overview of Action Selectors:
Action Selectors in ASP.NET MVC
- Action Selectors are built-in attributes provided in ASP.NET MVC and are directly influence our Controller's action methods.
- Action Selectors guide the URL Routers to respective action method of Controller which then opens up View for the user.
- Action Selectors are simple C# classes.
- There are 3 types of Action Selectors available in ASP.NET MVC, named as:
- ActionName
- NonAction
- ActionVerbs
- So, let's discuss each of them in detail:
1. ActionName Selector in ASP.NET MVC
- ActionName Selector (as the name suggests) is used to change the name of Action from the name of Controller's Method.
- Let's open the StudentController.cs file which we created in Tut # 06: Create a New Controller in ASP.NET MVC.
- I have added an action Method here Get() and above this method I have placed [ActionName("GetAction")], as shown in below figure:
- If we want to access this action method Get(), then we have to place localhost:12345/Student/Get in our browser.
- But after placing the ActionName Selector, now we have to use localhost:12345/Student/GetAction in order to call Get() Method.
- So, in this case the name of action is GetAction but the name of method is Get.
- But if we don't use ActionName Selector, then name of both Action and Method is Get.
- Let's have a look at what's the effect of ActionName Selector:
- As you can see in above figure that when we have used Get then we received Server Error.
- When we have used GetAction (assigned in ActionName) then our Method Get() is called.
- Here's the video demonstration of ActionName Selector in detail:
2. NonAction Selector in ASP.NET MVC
- NonAction Selector is another built-in attribute of ASP.NET MVC and as the name name suggests, it is used to remove the Action from action method.
- If you place NonAction Selector before an action method in your Controller then you won't be able to access that method directly from its action.
- URL Router will think this method doesn't exist, if its called directly.
- Let's add some code in our StudentController.cs file, as shown in below figure:
- I have added [NonAction] before our action method Get1(), that's how we specify nonAction Selector in ASP.NET MVC.
- If you have a look in the Index Method then you can see I have called Get1 there.
- Now when we open the Home Page of our site, then this Get1 action method will be called and it will work fine.
- But if we want to call the Get1 action method directly then it won't open up and will give us a Server error.
- That's because we have placed nonAction Selector before it.
- Results of both Home page & direct calling the action method are shown in below figure:
- So, its cleared from the above figure that nonAction has removed the action from our method and now its just a simple public method, which we can call from inside but no one can access it from outside directly.
- Here's the video demonstration of nonAction Selector, must watch it for live action:
3. ActionVerbs Selector in ASP.NET MVC
- ActionVerbs Selector is third built-in selector in ASP.NET MVC and is used to assign some specified HTTP request to action methods.
- It helps the URL router in selection of correct action method.
- Let's say you have two action methods in your project and they have a same name but you want to use one for GETting data and the second one for POSTing data.
- Let's have a look at the similar situation in below code:
- AS you can see in above figure that we have written two action methods of the same name Get1.
- So, now if you call it in your browser then you will get Server Error, as shown in below figure:
- So, now let's place our ActionVerbs Selector before one of these action methods, which one we want to call.
- I have placed the [HttpGet] before second action method and now because of this ActionVerbs Selector,URL Router will know which action method to call.
- Now when you open Get1 page, it will open fine.
- These ActionVerbs Selector are supported by ASP.NET MVC:
-
- HttpPost
- HttpGet
- HttpDelete
- HttpPut
- HttpOptions
- HttpPatch
- Here's the video demonstration of ActionVerbs Selector in detail:
So, that was all about Action Selectors in ASP.NET MVC. I hope you have enjoyed today's tutorial and now can easily use Selectors in ASP.NET. Thanks for reading. Have a good day !!! :)