ASP.NET

124K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm using ASP.NET MVC 4 and LINQ/SQL. I have an HTML page with a form where I want to render HTML input boxes based on a Model Class. In my view, I'm looping over the model and trying to generate an input box for each table row, but since the model is empty, the input boxes do not show. The model is empty because there is no data in the database yet as that is what I want to collect in my form. When there is data in the model, the values from the database should show in the form.

How can I render the empty input boxes, given that my model is initially empty.

Code is below:

@for (int i = 0; i < Model.Count; i++)
    {  
 <tr>

    <td>                           
      @Html.EditorFor(model => model[i].CustomerName, new { htmlAttributes = new { @class = "form-control" } })
    </td>

 </tr>
 }

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Both websites are on the same network, one is an intranet, one is an internet. We want to display some content (XML) from the Intranet site on the Internet site. Can the internet site serve content from the Intranet site if it's given permissions. Any suggestions?
0
Hey all,

I have an application that is being used for many clients. However, I've been asked to consolidate to a single code base. The application is also in need of a nice face lift to become more aesthetically pleasing as well as to increase the over all UI/UX. I've never event attempted something like this before so my question is: Would it best to develop/re-develop in C#/MVC or WebForms or modify the current VB.NET application to utilize new features etc.? All of the clients have a similar type of service, however, there are some drastic differences to features, the display of information etc. That being said, I'm not too sure of how cost effective it would be to attempt to consolidate into a single code base vs redeveloping the application utilizing as much code as possible with translation into C#.
0
Hi All,

can you please help me to know more about OS command injection and how to prevent it in asp.net web applications.

Many thanks
0
Hi,

I'm new to ASP.NET and having trouble trying to find a solution to getting empty date values to just be blank in my UI.  I'm using SQL Server and Linq / SQL and in my model I have this:

        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
	[Required(ErrorMessage = "Order date is required.")]
	public DateTime OrderDate{ get; set; }

Open in new window


In the UI I have this:

<td>
  @Html.EditorFor(model => model[i].OrderDate, new { htmlAttributes = new { @class = "form-control" } })
  @Html.ValidationMessageFor(model => model[i].OrderDate, "", new { @class = "text-danger" })
</td>

Open in new window

It renders the date as "01/01/0001" in the input box.

How can I modify the code I've provide to not render it that way and just show empty input box?

Thanks in advance.
0
I'm wanting to show a .gif while some processing goes on in the background, but I'm not able to get it to show, not even sure if it will 'animate', but I'm gonna hope for the best, once I can get it to show.

In my master page I have this:

    <style type="text/css">
        .lnkBtnTFBlue {
            display: none;
        }

        .LockOff {
            display: none;
            visibility: hidden;
        }

        .LockOn {
            font: arial;
            font-size: xx-large;
            font-weight: bolder;
            display: block;
            visibility: visible;
            position: absolute;
            z-index: 50000;
            top: 0px;
            left: 0px;
            width: 105%;
            height: 105%;
            background-color: #CCC;
            text-align: center;
            padding-top: 20%;
            filter: alpha(opacity=75);
            opacity: 1.5;
        }
    </style>

    <script type="text/javascript">
        $(document).ready(function (jQuery) {
            function LockScreen(str) {
                var lock = document.getElementById('LockPane');
                if (lock)
                    lock.className = 'LockOn';

                if (str != '') {
                    lock.innerHTML = str;
                }
            }
        });
</script>
.
.
.
    </form>
    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="js/response.min.js"></script>
    

Open in new window

0
I am a Senior .NET Full Stack Developer but want to have a sharper eye on the new technologies that are coming and the current technologies which are passing into the dustbin of history. What on-line industry publications are good for this?

Thanks
0
I am refreshing my memory about the various things which can cause a long response time on .NET MVC web pages and the tools to fix them.

A badly written stored procedure is the most obvious and this kind of bug can be uncovered first by looking at the Network tab of the browser and when the response time's too high, you may need to debug into the code to the point where the stored procedure is executed. You can also use SSMS to execute and fix it until the overall execution time becomes acceptable.

What other things can cause slow response and what methods uncover the problem?

Thanks
0
My HR department has asked me to develop something (ASP.NET vb -  SQL Server) for them but they say that no developer must have access to the data in the database.  What is the best way to achieve this, I'm struggling.
0
I have a table that hold the contents of a PDF document in a SQL Server Table COLUMN "DOCUMENT_CONTENT_TEXT"  .

When I attempt to search on the contents in this column it is taking a lot of time. And hence I was suggested to use FULLText Index feature. I am new to the same and I use the following script and I get the following error "Column 'DOCUMENT_CONTENT_TEXT' in table 'dbo.DMS_REPOSITORY' is of a type that is invalid for use as a key column in an index."

CREATE UNIQUE INDEX UI_DMS_REPOSITORY_DOCUMENT_CONTENT_TEXT ON dbo.DMS_REPOSITORY(DOCUMENT_CONTENT_TEXT);  

CREATE FULLTEXT CATALOG ft AS DEFAULT;
CREATE FULLTEXT INDEX ON dbo.DMS_REPOSITORY(DOCUMENT_CONTENT_TEXT)
   KEY INDEX UI_DMS_REPOSITORY_DOCUMENT_CONTENT_TEXT  
   WITH STOPLIST = SYSTEM;
GO

On googling I found that for Indexing a column the limit is 900 bytes but I am not sure if I could predict the size of the content being stored in this varchar(max) column.
0
Concerto's Cloud Advisory Services
LVL 4
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

I had this question after viewing Corrupt .NET Framework on Server 2012 Standard causing software issues, CBS Log attached, Help!.

Hi, my name is Jose Machado and wotk in IT department of an enterprise.
A few weeks ago, my windows 10 installed updates (I think that was) and when restarted the pc, I tried to open the powershell utility and it fails to start giving an error, but the Powershell ISE opened well.

I lived with the problem a few days more and I make a search and found a webpage that says that the problem is related with one of the windows updates that corrupts the powershell instalation and recommended to uninstall framework and install it again.

I tried to say that but don't find any .net framework under Program and features control panel. I started to uncheck the framework 3.5 and 4.7 under available windows features.
The problem remains and I made another search that guides me to the page  https://blogs.msdn.microsoft.com/astebner/2008/10/13/net-framework-setup-verification-tool-users-guide/  .

I tried to uninistall framework versions but the utility was running about three hours and I cancelled it.
When I restarted the pc the error continues when opening powershell.
I tried one more time without success, but it may advanced a bit because now I open powershell but now when I start the pc, …
0
I am new to ASP.NET MVC 5 and have questions regarding implementation of Code First using an Existing Database.

1. What folder should I add the  "ADO.NET Entity Data Model" to?  Should I add it to the "Models" folder or some other folder?  I have several tables in my existing database and I don't believe the root project folder is the best folder to store all these classes.

2.  Is there a 1 to 1 relationship between the Model and existing Table?   In other words, should each column in my Table have a matching property in a corresponding Model?
 
3. If not what is the best practice in designing models with existing database table structures.

Thank you in advance for you help!
0
I'm new to using ASP.Net MVC and getting this error in my view when I run my application.  

"The query results cannot be enumerated more than once"

@Html.DropDownList("CustomerNames", (IEnumerable<SelectListItem>)ViewBag.CustomerNameList, new {style="font-size:12px;"})

Open in new window


Any idea how to resolve this error?

Thanks in advance
0
Can you please tell me how to i fix that error?
screenshot.pngscreenshot2.pngscreenshot3.pngscreenshot4.png
0
Hello. I have a form.  On that form, I have some radiobutton lists.  On some of those list for example, if you choose no then a text box will display asking why you chose no.  But for some reason when you move to the next question and make another choice and another text box appears the previous one disappears.  I'm assuming it is because I have  autopostback=true on the lists. But if I take that out, nothing happens on the OnSelectedIndexChaged attribute of the list.   Here is the code:

Here is the radiobuttonlist where you can see where I call the function to make the panel visible and the autopostback is set to true. And I also have a validator on it to make the user choose something:
"<asp:RadioButtonList ID="rblConcernsAbtBehavior" runat="server" OnSelectedIndexChanged="rblConcernsAbtBehavior_SelectedIndexChanged" AutoPostBack="true">
                       <asp:ListItem>Yes</asp:ListItem>
                       <asp:ListItem>No</asp:ListItem>
                   </asp:RadioButtonList>
                    <asp:RequiredFieldValidator ID="concernsAbtBehaviorValidator" runat="server"
                                           ErrorMessage="Please choose one" Display="Dynamic"
                                           ControlToValidate="rblSeekingTreatmentAnotherDisability"></asp:RequiredFieldValidator>


Then I create panels for the textboxes that appear based on your choice.  Here is the panel
" <asp:Panel ID="pnlConcernsAbtBehavior" runat="server">
      …
0
Hi,

I have default.aspx page using frameset. I want to convert this using Masterpage. in asp.net and c#.

<%@ Page %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
	
  </HEAD>
<frameset rows="15%,85%"  border="0" frameBorder="0" frameSpacing="0">
     <frame src="AdminPage.aspx" NAME="Banner"  scrolling="no"/>
<FRAMESET border="0" frameBorder="0" frameSpacing="0" COLS="30%,70%">
    <FRAME SRC="index.aspx" NAME="frameName1">
    <FRAME SRC="blank.htm" NAME="frameName2">
</FRAMESET>
    </frameset>
</HTML>
 

Open in new window

0
Hi All,

I am having a vulnerability issues on my asp.net web application.

a potentially dangerous request.path value was detected from the client (:).

I already have <httpRuntime requestValidateMode="2.0" requestPathInvalidCharacters="" /> on my web config.
0
My old computer was crashed but I have all files save in my usb. I have another computer Dell Latitude D620  with same windows 7. I copied all of my vs 2010 projects and run all of my saved sql scripts back into sql server 2008. But when I try to load projects in visual studio 2010, I am keep getting error.
screenshot.pngscreenshot2.pngscreenshot4.pngscreenshot5.pngscreenshot3.png
0
Dear All,

I have experienced a weird problem at multiline edit for the title at the left side of the textbox.

At Chrome, the title shows at the  top beside the first line of the textbox.
At Firefox, the title shows at the bottom beside the first line of the textbox.

What's wrong with it ?

Thank you.
0
Free Tool: IP Lookup
LVL 10
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

This is one of those complicated problems.

I have two fields, boatRegNum and Payerret.

boatRegNum is  character data type and Payerret is money datatype.

We are using GridView to create dynamic rows.

The first row is created by default.

On this first row, user enters value for boatRegNum and Payerret.
For purpose of demonstration, the value for boatRegNum in first row is B3098 and value for Payerret for same row is 530.000

Then the user clicks the Add New Row button to add an additional row

In the newly added row, the user enters TY000 for boatRegNum and 90.00 for same second row.

The issue we are having so far is that when these values are inserted into the database, only the value for second row is inserted into the database.

The value for the first row is always ignored.

Any ideas what I am doing wrong?

Below are relevant code.

Thanks in advance for your help.

Markup:

    <%foreach (System.Data.DataRow row in dtAirInfoTable.Rows)
      {%>
    <tr>
	<td>
	    <span class="form-control" style="width: 493px; color: #0093B2; font-weight: bold;">
		<%=Convert.ToString(row.ItemArray[1].ToString())%></span>
	</td>
	<td align="left">
	    <span class="form-control txtPayerret" style="width: 326px; color: #0093B2; font-weight: bold;">
		<%=Convert.ToString(row.ItemArray[2].ToString())%></span>
	</td>
    </tr>
    <% } %>
    
    C#:
//datatable CurrTable
private DataTable LoadTable1(bool createIfMissing)
{
const string 

Open in new window

0
asp.net vb.net
I want to validate an email that uses accents, but with the validation that I have, I get a validation error:

.ValidationExpression = "^[\w\.\-\']+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"

How do I add all possible characters to this:
González@González.com

or other special characters.

thanks!
0
I have a general question that I need cleared up.  I have read several sources about web application design and the architecture used.  3 layers of development are typically used - presentation layer, business (logic) layer and data layer.  The only question I have is as follows:  Up to this point I have only used SQL server (data layer) and asp.net with vb.net code behind - my question is with ASP.net is that not the presentation layer of the development environment I am working with?

Could someone please make this clarification for me?

Thanks
0
Hello,
I have an asp page that sends data to a stored proc on sql server(see below).  
The data is getting sent like the following:  '3,4,5,6,7,8,9'
The problem is I do not want it sending the data with any single quotes.
When quotes are involved, the sp errors like this:
Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value '3,4,5,6,7,8,9' to data type int.

Any ideas would be greatly appreciated.

Dim connectionString2 As New Data.SqlClient.SqlConnection("Server=myserver;Database=mydb;Trusted_Connection=yes;")
Dim cmd2 As New System.Data.SqlClient.SqlCommand("mysp", connectionString2)
cmd2.CommandType = System.Data.CommandType.StoredProcedure
cmd2.Parameters.AddWithValue("@SELECTED_ITEMS", TextBox1.Text)
Using connectionString2
connectionString2.Open()
cmd2.ExecuteNonQuery()
End Using
connectionString2.Close()
connectionString2.Dispose()
0
I'm using SQL Server and learning ASP.NET MVC.  I want to format a value in my view as a percent.  It is stored in SQL Server as a float.  For example, I have a value like this in SQL Server:  95 and 95.24

In my model I have this:  

		
[DisplayFormat(DataFormatString = "{0:0.0%}", ApplyFormatInEditMode = true)]
public float? RetentionRate { get; set; }

Open in new window


<td>@Html.EditorFor(model => model.RetentionRate, new { htmlAttributes = new { @class = "form-control" } })</td>

Open in new window


The value is then showing on my webpage as :  9500.0%  rather than 95%.  How can I get it to display correctly?

If it's whole number it should show as 95%, if it has values to the right of decimal it should show as 95.33%

Any help appreciated
0
hi
Can i use resources file of asp web application in order to show an alert in javascript?
0

ASP.NET

124K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications