|
Hi Rick, thank you very much as I am new to the MVC, so when I am calling the Web Api Action method, its going to go to the Controller Action and returning from there the Json but not returning to the html page, how should I work with Web API when I want to load the html, do I need to call the html and then call the web api methods or should I set up the Api Controller Action methods as start point and then redirect to my html page?
It is basic question but this is my first MVC (MVC Web Api) application, that's why I need help. Because in MVC applications the url would be controller action methods and then it will be binded to the cshtml file. But how can I do that in Web Api because by default the Action method is not going to html at all.
2. Another question is if I am calling API controller Get action method and redirecting to html page then, why should I call it again to load data, because I have written the returning of Data in the Get action method just like above.
Please help me in understanding this confusion a little bit. Thank you very much Rick.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
You don't use WebAPI controllers to return HTML. You use them to load or change the raw data.
Your MVC controller returns an HTML view, which includes Javascript to make an AJAX request to the WebAPI controller. The WebAPI controller returns the raw data formatted as JSON, which your Javascript can then use to update the UI without having to reload the whole page.
You can also use your WebAPI from other types of applications - WPF, Windows Store apps, mobile apps, etc.
Getting Started with ASP.NET Web API 2 (C#) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for clearing all doubts my friend, its hard to do the things if we have done Web-farms long time and then worked only on back-end and middle tier for a while. I am sure I will enjoy programming the MVC and Web Api my friend, thanks again.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
hi to everyone
i need your help
i need to add GridView to a webpage using c#, without declare it in the page.aspx. is it possible?
i've tried in this way, but it never work
here the aspx
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<section ID="normalElement" runat="server"></section>
<section ID="adminPanel" runat="server"></section>
<section ID="myC" runat="server"></section>
</asp:Content>
here the c#
GridView view = new GridView();
DataTable tbl = new DataTable();
DataColumn idCol = tbl.Columns.Add("COL_A");
idCol.DataType = System.Type.GetType("System.String");
DataColumn nameCol = tbl.Columns.Add("COL_B");
nameCol.DataType = System.Type.GetType("System.String");
DataColumn descrCol = tbl.Columns.Add("COL_C");
descrCol.DataType = System.Type.GetType("System.String");
DataColumn delCol = tbl.Columns.Add("COL_D");
delCol.DataType = System.Type.GetType("System.Boolean");
view.DataSource = tbl;
view.DataBind();
myC.Controls.Add(view);
but when i run the page, never appears on the page.
i've tried to add an empty row, but never change
so: is it possible doing what i'm trying to do?
thank you
|
|
|
|
|
With your code, you have created the table tbl but you did not bind any data to it, those are columns you defined with no data so it will not be visible on the page.
Try something like below -
Have a place holder as below -
<asp:PlaceHolder ID="ph" runat="server" />
I am able to add the grid on page with below code.
protected void Page_Load(object sender, EventArgs e)
{
List<string> countrylist = new List<string>() { "India", "US" };
GridView grid = new GridView();
grid.AutoGenerateColumns = true;
grid.DataSource = countrylist;
grid.DataBind();
ph.Controls.Add(grid);
}
modified 20-Sep-20 21:01pm.
|
|
|
|
|
<asp:Panel id="panel_left" runat="server" Visible="false">
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdbGVRow" />
</Triggers>
<ContentTemplate>
<div class="row" style="padding-top:10px;">
<div class="col-md-12">
<div class="table-responsive" style="border: thin; overflow-y: hidden;">
<asp:GridView ID="grid_contact" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID"
OnRowDataBound="gv1_RowDataBound" OnPageIndexChanging="grid_contact_PageIndexChanging" AllowPaging="true" PageSize="10"
CssClass="table table-bordered table-hover" AutoPostBack="true" >
<HeaderStyle CssClass="table-bordered table-hover" Height="10px"/>
<PagerStyle cssClass="gridpager" HorizontalAlign="Center" />
<Columns>
<asp:TemplateField HeaderText="Detail" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:RadioButton ID="rdbGVRow" runat="server" OnCheckedChanged="radioChecked" AutoPostBack="true"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate><%#Eval("NAME")%> <%#Eval("LNAME")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="C_ID" HeaderText="Contact Id" SortExpression="C_ID" />
<asp:BoundField DataField="TITLE" HeaderText="Job Title" SortExpression="JOB TITLE" />
<asp:BoundField DataField="Added_on" HeaderText="Added On" />
<asp:TemplateField HeaderText="Status">
<ItemTemplate><div class="label label-lg label-success"><%#Eval("STATUS")%> </div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
|
|
|
|
|
Did you face any error?
modified 20-Sep-20 21:01pm.
|
|
|
|
|
Use this code,
protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Radiobuttonlb = e.Row.FindControl("rdbGVRow") as Radiobutton;
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);
}
also set
ClientIDMode="AutoID" for the Radiobutton
|
|
|
|
|
I am looking for information about how to integrate asp.net core or mvc and angular2, any information I would appreciate, thanks
|
|
|
|
|
Google will find you plenty.
|
|
|
|
|
|
Always best to try your own searches before posting questions.
|
|
|
|
|
The basics of .NET Core are, that this framework is highly extensible. There is nothing, by default in it. You add everything from scratch. Angular, Node.js, NPM etc. They are all added by the developers and you have to add them yourself as well.
There are however, templates provided, that you can use to create a new project.
Have a look here, Create an Angular 2 and .NET Core app that can be edited using Visual Studio 2017 - jonhilton.net, this provides a command that you can use to install extra packages and then utilize them in your projects by creating a new template-based project.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Just wondering if anyone has had some luck with integrating lightSlider, bootstrap and MVC.
I wrote something from scratch that worked better, but had trouble overlaying navigation over the pictures, otherwise it resized correctly with phones and desktops.
So I decided to try lightSlider since Sputnik was using it. Seems well written, but I can't figure out how to resize the pictures for various devices.
It's too tall for desktop use and wanted to scale it down. On phones in portrait, I get full picture height but it overflows hidden; and landscape it's just too tall for the screen.
You can see what I have here
http://50.20.227.154/Portfolio/Viewer/0
Just poking around for insight.
If it ain't broke don't fix it
|
|
|
|
|
Well I skipped over fixing the lightSlider and added the light-gallery to it. Then used my bower.json file to load both plugins automatically, and gulp to distribute the files correctly throughout the project. After getting all of that to work, I went back to doing research on the lightSlider and started going through a handful of tutorials.
Finally found this one
Js Tutorial - lightSlider - A lightweight touchable responsive Content slider
Which seemed to offer the best information on how to set it up.
So if all boiled down to the config file. So to save any one having the same trouble, here's a sample of what I used.
Still messing with the responsive properties to see how they work. Now that I have a stronger foundation, I can now build it out.
Overall, this lightSlider plugin is pretty slick, and the guy did a nice job writing it.
$(document).ready(function () {
$('#lightSlider').lightSlider({
item: 1,
autoWidth: false,
slideMove: 1,
slideMargin: 10,
addClass: '',
mode: "slide",
useCSS: true,
cssEasing: 'ease',
easing: 'linear',
speed: 400,
auto: false,
loop: false,
slideEndAnimation: true,
pause: 2000,
keyPress: false,
controls: true,
prevHtml: '',
nextHtml: '',
rtl: false,
adaptiveHeight: false,
vertical: false,
verticalHeight: 500,
vThumbWidth: 100,
thumbItem: 10,
pager: false,
gallery: true,
galleryMargin: 5,
thumbMargin: 5,
currentPagerPosition: 'middle',
enableTouch: true,
enableDrag: true,
freeMove: true,
swipeThreshold: 40,
responsive:
[
{ breakpoint: 1260, settings: { item: 2, thumbitem: 10, gallery: true, pager: true } },
{ breakpoint: 900, settings: { item: 2, thumbitem: 8, gallery: true, pager: true } },
{ breakpoint: 700, settings: { item: 1, thumbitem: 6, gallery: false, pager: true } },
{ breakpoint: 600, settings: { item: 1, thumbitem: 4, gallery: false, pager: true } }
],
onBeforeStart: function (el) { },
onSliderLoad: function (el) {
el.lightGallery({
selector: '#lightSlider .lslide',
subHtmlSelectorRelative: true
});
},
onBeforeSlide: function (el) { },
onAfterSlide: function (el) { },
onBeforeNextSlide: function (el) { },
onBeforePrevSlide: function (el) { }
});
});
If it ain't broke don't fix it
|
|
|
|
|
im using grid view, i set page size to 10 record and also put search bar to search record, the problem is that when i search record it shows records that is about 30 on page change it is reset to the default rather then show record on page 2 related to my search
|
|
|
|
|
You mean, you need to trim down the amount of results shown on the page?
Why are you selecting more than 10 records in the very first place? You should return only 10 records, on that page and then later on select the next 10 records, and so on.
You should also look at Pagination in ASP.NET, that will help you a lot in showing a better UX to the readers, who want to get something from your web application, read the following posts,
GridView Examples for ASP.NET 2.0: Paging and Sorting the GridView's Data
How To Implement Paging in GridView Control in ASP.NET
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hello Dudes,
I need a project on Employee leave management with timesheet, payroll and leave management using Asp.Net C#. please anyone provide me that code.
Thanks in advance.
Prasad
modified 8-May-17 14:49pm.
|
|
|
|
|
Hi Naveen,
It is not possible to get everything in a single project online. It is better to made it according to the requirement. If you want i can help you in to create that project.
|
|
|
|
|
Hi geeta goel, thank you for the replay. but at least i need leave management code and database tables. remaining parts i can implement.
|
|
|
|
|
This site is not here to provide code to order; try RentaCoder.
|
|
|
|
|
Hi Geeta goel,
Could you please give me brief description about salary structure in MNCs and also give me clarification about Leave management & Vacation Management. is leave and vacation both are same or different? how salaries calculated if any leave or vacation in a month. please give me example with 2 employees info.
Eagerly waiting for your response.
Thanks in Advance,
Prasad
|
|
|
|
|
Hello Naveen,
Leave & Vacation management both have different aspects in Corporate.
Leave also have a structure or we can say there are different types of leaves are there and they are alloted to the employees on some logical basis.
There are different ways of salary structure in MNC's. In some company's it is deciding on the grade levels and in some it is deciding on the experience basis.
It is not explained in a single paragraph. There are many logics behind the salary & leave management.
|
|
|
|
|
Thank you for your response.
Actually i'm implementing HRMS application. i want to include all those features like Leave,Vacation,Task,Employee Loans... etc. into one application. So, i need full clarity on Leave, Vacation and Salary Management. Till now i've completed upto employees management and task management. So, please give me at-least 50% knowledge.
What are the different ways for salary structures?
|
|
|
|
|
Hello Naveen,
There are different kinds of salary structure.
1. Hourly basis pay
2. Monthy basis pay
3. Weekly basis pay
4. Bi-weekly basis pay
It also depends that you are implementing the HRMS application for which country - India or USA or any other. There are some differences in their salary structures.
And also in salary structure, you can consider some more attributes.
I have given you a short description of the salary structures. You need to study in brief if you want to implement all full features.
|
|
|
|
|