|
Hi,
Am having two folders in my project containing two login.aspx pages of same name. So is it possible to use only one code behind page(login.aspx.cs) for two pages.
Please suggest me solution. Thanks in Advance.
|
|
|
|
|
While it may be possible, that will not be a good design. You might end up in issues regarding control names. Also, any future updates can cause problems. I would recommend keeping separate code behind files. If there are similar/same functionality, I would suggest extracting common bits to a utility class.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Thank you for your response.....
|
|
|
|
|
.ASPX pages should have a corresponding code-behind pages (.ASPX.CS files) ~ that's the WebForm's page model, each page is self-contained with its view and code organized together. This follows the Single Responsibility Principle.
If you have code that you think other pages or other areas in your application accesses it, then make them reusable methods. Create a Helper class as suggested and put all your method that you think are common. That way, you would just need to call a method from the Helper class instead of copying and pasting the same code all over again.
|
|
|
|
|
create a common base class Inheriting from page) with your generic login functionality; then inherit from that class in the two separate pages. You can then add folder-specific code as needed whilst avoiding duplication of your login functionality.
|
|
|
|
|
Thank you for your response.
Can you please provide me simple example with two aspx pages containing same name.
Thanks in Advance
|
|
|
|
|
Sure, no problem.
Take a look at cp.derektp.co.uk/page1[^] and cp.derektp.co.uk/subfolder/page1[^]
Two pages, same name (and the supporting class is the same name, "page1", too.)
Both pages inherit from class "commonpage" which is what supplies the common functionality (in this case, populating the middle line of text).
Cheers!
|
|
|
|
|
I spend 3 days now to fix this bug. I have in Classic ASP.NET environment (.NET version 4.0). I am trying to do 'Restful' from MVC by adding controllers folder.
I rebuilt the project and there is no issue until I load the page (http://localhost) then I have got error (NewtonSoft.Json). I have done everything according to suggestion from Internet but the issue won't go away. Thanks for any suggestion.
Here is my Global.asax:
<%@ Application Language="VB" %>
<%@ Import Namespace="System.io" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="System.Web.Http" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.ServiceModel.Activation" %>
<%@ Import Namespace="RBWeb" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
RBWebLibrary.Register(GlobalConfiguration.Configuration)
End Sub
<pre><pre>
My Web.Config
<runtime xmlns="">
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
------------------------------------------
and here is my RBWebLibrary.Register:
Public Shared Sub Register(ByVal config As HttpConfiguration)
config.Routes.MapHttpRoute(name:="DefaultApi", routeTemplate:="api/{controller}/{id}", defaults:=New With {.id = RouteParameter.Optional})
End Sub
and here is the packages.config
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
|
|
|
|
|
If you want someone to help you fix an error, then you need to tell us what the error is.
We need the full details of the error, not a random word picked out of the error message.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Your package says ver 11, not 6
Member 359326 wrote: <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
i am having problem with the position odf calender.
the calender is being displayed at TopLeft side of the page after clicking on text box for the first time,
after clicking on the text box it is displaying on the bottom right.
Sample code;
<tr>
<td align="left">
<asp:Label ID="txtdisptext" runat="server" Text="Appointment Date"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="txtCallReceivingDateTime" Width="100" runat="server" class="input"
MaxLength="25" TabIndex="13"></asp:TextBox>
<asp:CalendarExtender ID="txtCallReceivingDateTime_CalendarExtender" runat="server"
TargetControlID="txtCallReceivingDateTime" Enabled="True" Format="dd/MM/yyyy"
CssClass="cal_Theme1" PopupPosition="BottomRight">
</asp:CalendarExtender>
<%--<asp:CalendarExtender ID="CalCallReceDate" runat="server" >
</asp:CalendarExtender>--%>
<asp:DropDownList ID="ddlCallAttendedOnTimeHours" runat="server" Width="40px" CssClass="inputddl">
<asp:ListItem Value="0">00</asp:ListItem>
<asp:ListItem Value="1">01</asp:ListItem>
<asp:ListItem Value="2">02</asp:ListItem>
<asp:ListItem Value="3">03</asp:ListItem>
<asp:ListItem Value="4">04</asp:ListItem>
<asp:ListItem Value="5">05</asp:ListItem>
<asp:ListItem Value="6">06</asp:ListItem>
<asp:ListItem Value="7">07</asp:ListItem>
<asp:ListItem Value="8">08</asp:ListItem>
<asp:ListItem Value="9">09</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
<asp:ListItem Value="12">13</asp:ListItem>
<asp:ListItem Value="14">14</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="16">16</asp:ListItem>
<asp:ListItem Value="17">17</asp:ListItem>
<asp:ListItem Value="18">18</asp:ListItem>
<asp:ListItem Value="19">19</asp:ListItem>
<asp:ListItem Value="20">20</asp:ListItem>
<asp:ListItem Value="21">21</asp:ListItem>
<asp:ListItem Value="22">22</asp:ListItem>
<asp:ListItem Value="23">23</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlCallAttendedOnTimeMinutes" runat="server" Width="40px" CssClass="inputddl">
<asp:ListItem Value="0">00</asp:ListItem>
<asp:ListItem Value="1">05</asp:ListItem>
<asp:ListItem Value="2">10</asp:ListItem>
<asp:ListItem Value="3">15</asp:ListItem>
<asp:ListItem Value="4">20</asp:ListItem>
<asp:ListItem Value="5">25</asp:ListItem>
<asp:ListItem Value="6">30</asp:ListItem>
<asp:ListItem Value="7">35</asp:ListItem>
<asp:ListItem Value="8">40</asp:ListItem>
<asp:ListItem Value="9">45</asp:ListItem>
<asp:ListItem Value="10">50</asp:ListItem>
<asp:ListItem Value="11">55</asp:ListItem>
</asp:DropDownList>
</td>
<td align="left">
<asp:Label ID="lblRmrkstext" runat="server" Text="Remarks"></asp:Label>
</td>
<td align="right">
<asp:TextBox ID="textRemarks" runat="server" Style="padding-left: 11px;" class="input"
TextMode="MultiLine" TabIndex="15"></asp:TextBox>
</td>
</tr>
Thank you in advance
|
|
|
|
|
Hi,
I am using DropdownListFor in my MVC cshtml page, but I am getting the above error:
@Html.DropDownListFor(model => model.PKModeOfServiceLKPId, new SelectList(Model.ModeOfServiceLKPList, "PKModeOfServiceLKPId", "Description") , new { @class = "form-control input-sm", style = "width:300px;", @id = "idDDLForModeOfServiceCode"})
But I am getting the values in the Model as below;
public List<MCMSSFCrosswalk> GetMCMSSFCrosswalkList()
{
using (BHPRVEntities pe = new BHPRVEntities())
{
var prov = pe.Usp_Get_MCMSSFCategoryCrosswalkList();
return prov.Select(p => new MCMSSFCrosswalk()
{
Id = p.Id,
Description = p.MCMSSFCrosswalkDescription,
MCModeOfServiceCode=p.ModeOfServiceCode,
FKServFuncCatMCModeOfServiceId = p.FKServFuncCatMCModeOfServiceId,
ModeOfServiceCode=p.ModeOfServiceCode,
ServiceFunctionCategoryCode=p.ServiceFunctionCategoryCode,
ServiceFunctionCategoryDescription=p.ServiceFunctionCategoryDescription,
CreatedDate = ((p.CreatedDate != null) && (!DBNull.Value.Equals(p.CreatedDate))) ? p.CreatedDate : null,
CreatedBy = p.CreatedBy,
ModifiedDate = ((p.ModifiedDate != null) && (!DBNull.Value.Equals(p.ModifiedDate))) ? p.ModifiedDate : null,
ModifiedBy = p.ModifiedBy,
IsValid = ((p.IsValid == null) || (DBNull.Value.Equals(p.IsValid))) ? true : p.IsValid,
ModeOfServiceLKPList=GetListOfModeOfServices(),
MCModeOfServiceLKPList = GetListOfMCModeOfServices(),
ServiceFunctionCategoryLKPList = GetListOfServiceFunctionCategories()
}).ToList();
}
}
My Model is as below:
public class MCMSSFCrosswalk
{
private List<ModeOfServiceLKP> listOfModeOfServiceLKP = new List<ModeOfServiceLKP>();
private List<MCModeOfServiceLKP> listOfMCModeOfServiceLKP = new List<MCModeOfServiceLKP>();
private List<ServiceFunctionCategoryLKP> listOfServiceFunctionCategoryLKP = new List<ServiceFunctionCategoryLKP>();
public int Id { get; set; }
public string Description { get; set; }
public string RevenueCode { get; set; }
public string ProcedureCode { get; set; }
public string Modifier1 { get; set; }
public string Modifier2 { get; set; }
public string Modifier3 { get; set; }
public string Modifier4 { get; set; }
public int FKServFuncCatMCModeOfServiceId { get; set; }
[DisplayName("ModeOfServCode")]
public string ModeOfServiceCode { get; set; }
public int? PKModeOfServiceLKPId { get; set; }
[DisplayName("ModeOfServDescr")]
public string ModeOfServiceDescription { get; set; }
[DisplayName("ServFuncCatCode")]
public string ServiceFunctionCategoryCode { get; set; }
public int? PKServiceFunctionCategoryLKPId { get; set; }
[DisplayName("ServFuncCatDesc")]
public string ServiceFunctionCategoryDescription { get; set; }
public string MCModeOfServiceCode { get; set; }
public int? PKMCModeOfServiceLKPId { get; set; }
public string MCModeOfServiceDescription { get; set; }
public DateTime? CreatedDate { get; set; }
public string CreatedBy { get; set; }
public DateTime? ModifiedDate { get; set; }
public string ModifiedBy { get; set; }
public bool? IsValid { get; set; }
public int? LookupTableId { get; set; }
public List<ModeOfServiceLKP> ModeOfServiceLKPList { get { return this.listOfModeOfServiceLKP; } set { this.listOfModeOfServiceLKP = value; } }
public List<MCModeOfServiceLKP> MCModeOfServiceLKPList { get { return this.listOfMCModeOfServiceLKP; } set { this.listOfMCModeOfServiceLKP = value; } }
public List<ServiceFunctionCategoryLKP> ServiceFunctionCategoryLKPList { get { return this.listOfServiceFunctionCategoryLKP; } set { this.listOfServiceFunctionCategoryLKP = value; } }
}
But the break point int the method GetMCMSSFCrosswalkList() is not even hitting just when the Page getting loaded its breaking at the @Html.DropDownListFor, PKModeOfServiceLKPId, I am not sure why is it breaking. I am little bit new to MVC, can anybody please help me, all I have to do is to load the list of these three objects in three different dropdowns and select the items of those dropdowns depending upon the Primary Keys we get.
I really need some help, any support would be very very helpful - thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
If the breakpoint isn't getting hit, then you haven't called the method.
What does the code in your action method look like?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I finally figured out how to integrate Angular 6 into a .Net 2.1 core project, and get all my scss and scripts loaded and the first page loaded correctly.
So now I'm on to the Angular Questions. What section would be the proper place to post them?
My Question:
I understand the Home component, module and routes for a single component.html page. But I really want to add a page called 'websites' and use the home.component, home.module and home.routes for it, basically just add another HTML file.
Is is possible for me to just add another html file to the home.component, home.module and home.routes?
Or do I have to make a component, module and route for every page?
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Not the best person to answer this, but you could try posting Angular related questions to Web Development forum section: Web Development Discussion Boards[^], Otherwise if the issue is more on ASP.NET Core side, you can post your query here.
I'm not aware of an official forums discussion for Angular, but you could also try posting Angular queries at SO: Newest 'angular' Questions - Stack Overflow[^]
|
|
|
|
|
I was just thinking about this post an hour ago.
Well I heard the sound of crickets here, so perhaps I'll have to try another venue for Angular questions.
I'm past the .net core part of Angular, and I'm on pure Angular typescript and router now.
I'm starting to see the downside of using Angular with .Net Core 2, in which I have to double build each time I change something, which is time consuming.
But thanks for the answer!
If it ain't broke don't fix it
Discover my world at jkirkerx.com
modified 1-Aug-18 12:00pm.
|
|
|
|
|
You bet. Good luck on exploring Angular!
|
|
|
|
|
Hi,
I am doing an mvc application.
I am unable to send data from view to controller.
View code
@model IEnumerable<studentcourse.models.course>
Index
@foreach(var item in Model)
{
- @Html.ActionLink(item.coursename,"Details","Home",new {name=item.coursename})
}
controller code:
public ViewResult Details(string name)
{
return View(db.students.Where(x=>x.cousename==name.ToString()).ToList());
}
the parameter value for "string name" is showing null.
thanks in advance
|
|
|
|
|
Try replace this line
@Html.ActionLink(item.coursename,"Details","Home",new {name=item.coursename})
with
@Html.ActionLink(item.coursename,"Details","Home",new {name=item.coursename}, null)
c# - HTML.ActionLink method - Stack Overflow[^]
Bryian Tan
|
|
|
|
|
I'm trying to figure out the right way to play around with Angular in my .Net Core 2.1 project.
Right now I just have a folder with Angular in it, and created a bundle. In the View I created markup to call the controller and render the output.
It works fine for now, at least I think it does.
But I used some other examples, such as using ng new ClientApp and followed the instructions. Now my project loads the Angular index page instead of my views. Funny how that sure works fine, and I guess I pulled it off.
I'm trying to create some sort of hybrid here, where a couple of pages can be Angular, while the others are MVC.
Am I correct is assuming the above is strictly for creating a pure Angular project? A pure Angular project in which everything is Angular, or is it possible to for me to mix the two together, and perhaps a hint on how.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I honestly wouldn't recommend it. The purpose of Angular and other SPA starter frameworks is to push the rendering responsibility down to the client side; splitting that responsibility will only make the application harder to maintain as people will need to play the "where did this render?" game.
There's another important factor to consider, and I think it's the one that's tripping you up: the routing mechanism. Angular uses a routing mechanism that is completely separate from the one used by MVC. Those two need to be setup to agree with each other (or at least don't overlap) before anything else. If all rendering is in NG, the MVC router pretty much gets relegated to controller location for AJAX requests - which NG will play nicely with out of the box - but as soon as you need to serve pages all that changes.
So long answer short: the right way to use Angular in a .NET Core project is to not straddle your presentation layer between client and server. Let the client be your presentation layer, and only business/DAL logic on the server.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
I didn't think of the router part. I wonder if I can take my Portfolio controller and remove it from MVC, and recreate that in Angular.
Then try writing a Angular Image Index and Gallery.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I determined that mixing MVC and Angular is probably not a good way to learn, so I decided to just create a .Net Core 2.1 App with Angular.
I'm having trouble understanding node_modules, wwwroot and Angular.
This may not come out or sound clear here;
But in the angular.json , I added mdbootstrap, fontawesome from node_modules.
So I see a styles.js file appended to the page displayed in the browser source. I would assume that this file loads my css or sass. But none of my mdbootstrap styles render. So I was thinking perhaps its because the source of the css or sass is in node_modules, and only content in the wwwroot will be displayed. My old school thinking here is the link tags in the header.
So OK, perhaps I need to somehow generate all this to the wwwroot .
Now comes WebPack. I guess with a proper WebPack configuration, all my custom assets such as images, css, sass would be built and copied to wwwroot .
My question is that this part is fuzzy to me, and I'm not sure which direction to go here and was looking for a suggestion.
I would like to try the mdboostrap, it's JQuery and FontAwesome in my learning project here.
A 2nd issue, is that I loaded WebPack from Package.Json , and when I run my WebPack.Config.js in Webpack Task Runner, it complains about using let and use strict .
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I decided to go with webpack, and fixed the error, updated node and npm in the project.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
I am new to MVC want to load 5 different Partial Views on Javascript Conditions, like for example I have a dropdown list, on the page, depending upon the dropdown selection I want to load different Partial View, I am not able to use ViewBag as VieBag value is not changing depending upon the Dropdown list box, it seems I have to do that using jquery or javascript, can anybody please help me in doing it? Even if we can do it by using View is also fine if it is possible, in means if I can achieve it, it would be great. Thanks in advance its little bit urgent, please need your help.
@{
ViewBag.Title = "ListLookups";
}
<script>
var UserName = "@ViewBag.UserName";
</script>
<style>
.k-edit-form-container {
width: 500px;
}
</style>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="tab-content" id="dvtabs" style="padding-top:10px;">
<label class="col-md-4 control-label">Administration for Table: </label>
@(Html.Kendo().DropDownList().Name("Lookup").OptionLabel("Select")
.DataTextField("Text")
.DataValueField("Value").HtmlAttributes(new { style = "width:280px;", @id = "drpLookup" })
.DataSource(dataSource => dataSource.Read(read => read.Action("GetListOfLookupTables", "Admin")))
.Events(e =>
{
e.Change("GetLookupTableValue");
})
<pre>
)
</div>
<div style="margin-top: 5px; padding-left:3%; padding-right:2%">
<div>
<div>
<h4 id="myHeader"></h4>
</div>
Here should be my Conditions like (if x==y)
@Html.Partial("_LookupTableNoCode")
else if (x==z)
@Html.Partial("_LookupTableCode")
}
function LookupPopUpTitle(e)
{
var lookupTableName = $("#drpLookup").data("kendoDropDownList").text();
<pre>
if (e.model.isNew())
{
$('.k-window-title').text("Add " + lookupTableName);
e.model.set("CreatedBy", UserName);
//e.model.set("State", "California");
//e.model.set("EffectiveDateFrom", new Date());
}
else
{
$('.k-window-title').text("Edit " + lookupTableName);
e.model.set("ModifiedBy", UserName);
}
}
$(document).ready(function ()
{
//alert("test 1");
var grid = $("#LookupGrid").data("kendoGrid");
grid.dataSource.read();
//alert("test 2");
})
function ConvertLEDate(val)
{
if (val != '' && val != null && val != 'undefined')
{
var date = new Date(parseInt(val.substr(6)));
date = date.getMonth() + 1 + "/" + date.getDate() + "/" + date.getFullYear();
return date;
}
return null;
}
function DateFormat(val)
{
if (val != '' && val != null && val != 'undefined')
{
try
{
var dt = val.getMonth() + 1 + "/" + val.getDate() + "/" + val.getFullYear();
return dt;
}
catch (e)
{
return ConvertLEDate(val);
}
}
return '';
}
function ViewLookupTableValues(e)
{
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var PkContactId = dataItem.Id;
window.location.href = '@Url.Action("GetProgramTypeById", "ProgramType")?id=' + Id + "&Type=View";
}
function GetLookupTableId()
{
return {
LookupTableId: $("#drpLookup").data("kendoDropDownList").value()//, ParentId: PkPrvId, ParentTypeCode: 'PRV'
};
}
function GetLookupTableValue(e)
{
if ($("#drpLookup").data("kendoDropDownList").text() != 'Select')
myHeader.innerText = "List of " + $("#drpLookup").data("kendoDropDownList").text();
else
myHeader.innerText = "";
//myHeader.innerText = "List of " + $("#drpLookup").data("kendoDropDownList").text();
var grid = $("#LookupGrid").data("kendoGrid");
grid.dataSource.read();
}
function GetLookupTableValue1(e)
{
var grid = $("#LookupGrid").data("kendoGrid");
grid.dataSource.read();
}
</pre>
else if its possible with ViewBag is also fine like below, in any means if it is possible, please help me, I need your help friends please.
(if ViewBag.Id==y)
@Html.Partial("_LookupTableNoCode")
else if (ViewBag.Id==z)
@Html.Partial("_LookupTableCode")
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|