|
I have created a test ASP.NET Core MVC application in VS 2022.
I configured individual authentication so it automatically created a database in the (localdb)\MSSQLLocalDB database server for all authentication chores.
I need to deploy the test application to a web server along with its database.
Where in the application do I point it to the web server's database server? The appsettings.json file doesn't contain a connection string for the (localdb), so I don't know if that's the right place for a different connection string.
If you could point me in the right direction, I'll be grateful.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
The connection string is normally stored in the web.config file. If you haven't yet, try searching the entire solution for 'localdb'.
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
Thanks Ron. I found the place where the default connection string is defined. Problem solved.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
How do C programming principles influence C# .NET development, and how can understanding C help in mastering C#? Discuss the similarities in syntax, differences in memory management, the role of pointers, object-oriented programming concepts, platform independence, and use case differences. Share your experiences and insights on transitioning from C to C#.
|
|
|
|
|
Don't post the same thing all over the site. Once is enough. Any more than that, and you're going to get eyed as a spammer and treated as such.
|
|
|
|
|
how to fix "assertion failed : unrecognized tag script" error
Anant Patil
Broadllyne Technology
|
|
|
|
|
Probably by correcting the code that causes it. But unless you show us the actual code there is not much that can be suggested. Please edit your question and add complete details of the problem.
|
|
|
|
|
The error typically occurs when there is an issue with unrecognized tags within your application. This could happen if you are using a tag that is not recognized or if there's a syntax error in your markup. Show some code so we can understand the error rather than trying to read minds on where the issue is occurring.
|
|
|
|
|
I want to build my own gallery module and add it into Umbraco CMS.
is it difficult to do this?
diligent hands rule....
|
|
|
|
|
|
I am planning the development of ASP.NET Core MVC Razor application and am looking for FREE library of some quality that supports MVC/Razor development. I see plenty of commercial libraries like Kendo UI that can be used, but I am looking for something like Open Source Material Design. As far as I know, Material UI is usable only from SPA/React, and I want to develop MVC/Razor application that is Round-trip (Request/Response), not an SPA application like React.
|
|
|
|
|
Hello
Please note that I am sorry to take anyone's time out of whatever busy life they might have. So I have a professional class project which unfortunatly is related to coding even though its just about the first and last time this is supposed to happen. I am supposed to write a .net code in VS for windows VM that will show ip address of the VM from a browser. I am not a programmer nor any career close to that so I am completely stuck and dont want to just call it a day without trying every possible avenue on the internet. I have been on this for 24hrs trying on my own with different online forums even chatgpt/Bard but to no avail so I need help. Just help write the code to help a brother out please. I saw that VS has a bunch of asp.net templates so I kept shoveling between asp.net core web api and asp.net web app (razor pages) but no luck. This project is in aws and its part of the requirement I need to complete the project.
Am gratefull
modified 25-Nov-23 0:11am.
|
|
|
|
|
Sorry, but this site does not provide code to order. You need to go back to your teacher and explain why this task is beyond your capabilities.
|
|
|
|
|
Maybe view the question below this one, Richard has added very valuable links that will point you in the right direction - Starting in ASP.NET[^]
|
|
|
|
|
appache05 wrote: I am supposed to write a .net code in VS for windows VM that will show ip address of the VM from a browser
Just noting that if one has no programming experience then this is a very difficult project to start with.
So something odd is going on. For example you skipped a pre-requisite class. Or the teacher doesn't know what they are doing. Or perhaps you only needed to select a project from a multiple selection and you selected one that did not fit your skill set.
appache05 wrote: though its just about the first and last time this is supposed to happen.
...or perhaps you are mistaken about that in terms of what the class is doing in general.
|
|
|
|
|
I am a consultant, not a developer, so I mainly develop small customizations to my company's software as opposed to coding entire applications from scratch and selling them.
I have basic experience with HTML, though admittedly I've never personally written HTML code that has a div tag. I'm somewhat familiar with XML style sheets but it's been awhile. I remember that classic ASP code basically just dynamically produced HTML and sent it from the server to the client - I'm honestly not sure whether or not ASP.Net does the same thing. I'm somewhat familiar with JavaScript and VBScript and somewhat understand the difference between client-side code and server-side code. I've heard that there's this thing called Ajax - all I really know about it is that it makes it easier to write client-side code that actually interacts with the server. I've heard that my company's website uses the React framework but I don't know what that is. Regardless, ASP.Net web parts can be coded and then "pasted into" custom areas on the company's website. There are very rare needs to code entire ASPX web pages, but the ASCX controls are used a LOT.
I need to get to the point where I can code reasonably complex and dynamic ASP.Net web parts to paste into the main website. There are frequent business needs for which the right technical solution is either client-side code, server-side code or both. In most cases, the user interface is fairly simple, but I've seen some get fairly complex, i.e. the entire form can change based on a selection in a dropdown (i.e. a dropdown could include 4 or 5 different reports they can generate, and the input into each report could be totally different). I've also seen web parts that actually have a dynamic number of dropdowns on them (how that could POSSIBLY be the most efficient user interface for a given business need is beyond me, but I've seen it happen.
So here's the question - based on what little I know, what should I start studying/reading/practicing to get to where I can reach my goal? Any suggested online training sites and/or books I could buy to start learning?
Hope I elucidated the question sufficiently for it to be actionable.
Thanks
DalTXColtsFan
|
|
|
|
|
|
I wish it was a little easier to post screenshots here, but what's going on is my SelectedIndexChanged event handler is being triggered if I choose any item in the dropdown OTHER THAN THE TOP ONE. When I choose the top item in the dropdown, Page_Load is getting fired, but not SelectedIndexChanged. What's going on?
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="First2023WebUserControl.ascx.cs" Inherits="First2023Control.UserControls.First2023WebUserControl" %>
<asp:Label ID="Label1" runat="server" Text="Hello Year 2023"></asp:Label>
<p>
</p>
Category:<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged">
</asp:DropDownList>
<p>
Subcategory:
<asp:DropDownList ID="ddlSubcategory" runat="server" AutoPostBack="True">
</asp:DropDownList>
</p>
<p>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
protected void Page_Load(object sender, EventArgs e)
{
Label3.Text = "In Page Load selected index is " + ddlCategory.SelectedIndex.ToString();
XXXDbSupport objDBSupport = new XXXDbSupport();
DbCommand objDBCommand = objDBSupport.CreateDbCommand();
objDBCommand.CommandType = CommandType.Text;
string sSQL = "select distinct isnull(Category,'(blank)') as ProdCat from xxx_product order by isnull(Category,'(blank)')";
objDBCommand.CommandText = sSQL;
DataTable objDBTable = objDBSupport.FillDataTable(objDBCommand);
if (objDBTable.Rows.Count > 0)
{
ddlCategory.DataTextField = "ProdCat";
ddlCategory.DataValueField = "ProdCat";
ddlCategory.DataSource = objDBTable;
ddlCategory.DataBind();
}
else
{
ddlCategory.Text = "n/a";
}
}
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text = "The selected index changed to " + ddlCategory.SelectedIndex.ToString();
XXXDbSupport objDBSupport = new XXXDbSupport();
DbCommand objDBCommand = objDBSupport.CreateDbCommand();
objDBCommand.CommandType = CommandType.Text;
string sSQL = "select distinct isnull(SubCategory,'(blank)') as SubCat from xxx_product ";
if (ddlCategory.Text == "(blank)")
{
sSQL = sSQL + "where isnull(Category,'(blank)') = '(blank)' order by isnull(SubCategory,'(blank)')";
}
else
{
sSQL = sSQL + "where Category = '" + ddlCategory.Text + "' order by isnull(SubCategory,'(blank)')";
}
objDBCommand.CommandText = sSQL;
DataTable objDBTable = objDBSupport.FillDataTable(objDBCommand);
if (objDBTable.Rows.Count > 0)
{
ddlSubcategory.DataTextField = "SubCat";
ddlSubcategory.DataValueField = "SubCat";
ddlSubcategory.DataSource = objDBTable;
ddlSubcategory.DataBind();
}
else
{
ddlSubcategory.Text = "n/a";
}
}
|
|
|
|
|
Stick your Page_load code inside a !Postback and see what happens.
if (!IsPostBack)
{
}
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
When I do that the dropdowns don't get refreshed at all. Isn't that what's expected? When the user chooses an entry from the dropdown is issues a postback, so Page_Load won't do anything unless !IsPostBack is True, which it won't be.
|
|
|
|
|
Ron is absolutely correct, When the page is loaded for the first time, the 'Page_Load' event is triggered, and the 'ddlCategory_SelectedIndexChanged' event is not fired because the 'AutoPostBack' property is set to True. However, when you select the first item in the dropdown, the page is posted back to the server, and the 'Page_Load' event is triggered again. This causes the selected index to be reset, and the 'ddlCategory_SelectedIndexChanged' event is not fired.
You should only populate the dropdown list during the initial page load and not on subsequent 'postbacks'. You can do this by wrapping your code inside the 'Page_Load' event with a check for '!IsPostBack' -
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Label3.Text = "In Page Load selected index is " + ddlCategory.SelectedIndex.ToString();
XXXDbSupport objDBSupport = new XXXDbSupport();
DbCommand objDBCommand = objDBSupport.CreateDbCommand();
objDBCommand.CommandType = CommandType.Text;
string sSQL = "select distinct isnull(Category,'(blank)') as ProdCat from xxx_product order by isnull(Category,'(blank)')";
objDBCommand.CommandText = sSQL;
DataTable objDBTable = objDBSupport.FillDataTable(objDBCommand);
if (objDBTable.Rows.Count > 0)
{
ddlCategory.DataTextField = "ProdCat";
ddlCategory.DataValueField = "ProdCat";
ddlCategory.DataSource = objDBTable;
ddlCategory.DataBind();
}
else
{
ddlCategory.Text = "n/a";
}
}
}
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text = "The selected index changed to " + ddlCategory.SelectedIndex.ToString();
XXXDbSupport objDBSupport = new XXXDbSupport();
DbCommand objDBCommand = objDBSupport.CreateDbCommand();
objDBCommand.CommandType = CommandType.Text;
string sSQL = "select distinct isnull(SubCategory,'(blank)') as SubCat from xxx_product ";
if (ddlCategory.Text == "(blank)")
{
sSQL = sSQL + "where isnull(Category,'(blank)') = '(blank)' order by isnull(SubCategory,'(blank)')";
}
else
{
sSQL = sSQL + "where Category = '" + ddlCategory.Text + "' order by isnull(SubCategory,'(blank)')";
}
objDBCommand.CommandText = sSQL;
DataTable objDBTable = objDBSupport.FillDataTable(objDBCommand);
if (objDBTable.Rows.Count > 0)
{
ddlSubcategory.DataTextField = "SubCat";
ddlSubcategory.DataValueField = "SubCat";
ddlSubcategory.DataSource = objDBTable;
ddlSubcategory.DataBind();
}
else
{
ddlSubcategory.Text = "n/a";
}
}
|
|
|
|
|
|
OK, I'll put this in as few words as possible, and please bear with me if I am not clear, I'm still relatively new to this stuff:
So my company has a website we roll out to our customers, and the developers provided a base class to the consultants to use to create custom web parts. The website has a "design mode" built into it where an admin can divide the page up into sections, and basically assign a custom web part to that section of the page. The ascx and dll for the web part obviously have to be on the IIS server where the website can "see" it. I'm not sure exactly how that works technologically, i.e. if it's a master page with individual pages or if it's like a div or whatever.
Anyway, I tried to create a simple webpart with two dropdowns, one of which depends on the other, and a button. The labels and dropdowns appear to be initializing correctly. When I click the button, it correctly updates the label but it clears the dropdowns. Changing the selection in either dropdown appears to re-initialize the entire form including clearing the dropdowns.
Lastly, I could be wrong but I don't believe that the code in ddlCategory_SelectedIndexChanged is getting fired as a result of the dropdown getting clicked - I think it's only getting ran when I call it explicitly. Again, I could be wrong, but I feel like any time a "postback" is issued, only Page_Load is getting fired off, and the controls are all getting cleared/initialized before any of the code in Page_Load is actually run.
I'll pause there for a moment - does anyone see anything in *my* code that could be causing this incorrect result? Before I talk about how I could troubleshoot it within the framework of the rest of my company's website let's establish that.
Thanks
DTXCF
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="First2023WebUserControl.ascx.cs" Inherits="First2023Control.UserControls.First2023WebUserControl" %>
<asp:Label ID="Label1" runat="server" Text="Hello Year 2023"></asp:Label>
<p>
</p>
Category:<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged">
</asp:DropDownList>
<p>
Subcategory:
<asp:DropDownList ID="ddlSubcategory" runat="server" AutoPostBack="True">
</asp:DropDownList>
</p>
<p>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Custom1.Custom2.Web.Framework;
namespace First2023Control.UserControls
{
//public partial class First2023WebUserControl : System.Web.UI.UserControl
public partial class First2023WebUserControl : Custom1.Custom2.Web.Framework.UserControlBase
{
[Property(DisplayName = "Message Text")]
public string MessageText
{
get
{
return Label1.Text;
}
set
{
Label1.Text = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
ddlCategory.Items.Add("FirstCat");
ddlCategory.Items.Add("SecondCat");
ddlCategory_SelectedIndexChanged(sender, e);
}
else
{
Label1.Text = "I posted back";
}
}
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text = "The selected index changed";
if (ddlCategory.SelectedValue == "FirstCat")
{
ddlSubcategory.Items.Clear();
ddlSubcategory.Items.Add("FirstCatFirstSubCat");
ddlSubcategory.Items.Add("FirstCatSecondSubCat");
}
else
{
ddlSubcategory.Items.Clear();
ddlSubcategory.Items.Add("SecondCatFirstSubCat");
ddlSubcategory.Items.Add("SecondCatSecondSubCat");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Label3.Text = "Someone clicked the button";
}
}
}
|
|
|
|
|
Your issue might be related to the page lifecycle and the way ASP.NET handles postbacks.
The key part of your issue is likely in your 'Page_Load' method where you are clearing and populating the dropdown list only if it's not a postback. The 'Page_Load' event occurs before the 'Button1_Click' event, so when you click the button, the 'Page_Load' event is triggered again before the button click event, and the dropdowns are reinitialized, you can change the behaviour -
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlCategory.Items.Add("FirstCat");
ddlCategory.Items.Add("SecondCat");
ddlCategory_SelectedIndexChanged(sender, e);
}
else
{
Label1.Text = "I posted back";
}
}
|
|
|
|
|
Thanks for the reply.
So Page_Load always re-initializes controls every time it's invoked, and any postback always triggers Page_Load?
If it's clearing and re-populating the dropdowns every time it posts back, how is it possible to code it in such a way that the SubCategory dropdown's values depend on the selected value of Category?
Again, sorry if I'm not asking the right questions, I hope this makes sense.
Thanks
DTXCF
|
|
|
|