ASP.NET

123K

Solutions

35

Articles & Videos

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

Hello Experts,

I'm having trouble retrieving/displaying the City value from the database to the City drop down list based on the selected Customer's ID that I wish to Edit.

When I select a Customer to Edit it populates the data from the database properly except for the City drop down list. The City drop down list will show "Select a City" along with all Cities that are related to the State in the State drop down list.

If I select another state then it loads all cities for the selected state properly.

The problem is that it does not show the City value for the City drop down list like it should when I first load the page.

Edit View:
@model WebAppCascadeDropDown.ViewModels.CustomerFormVM

@{
    ViewData["Title"] = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm("Edit", "Customer"))
{
    <div class="form-group">
        @Html.LabelFor(c => c.FirstName)
        @Html.TextBoxFor(c => c.FirstName, new { @class = "form-control" })
    </div>

    <div class="form-group">
        @Html.LabelFor(c => c.LastName)
        @Html.TextBoxFor(c => c.LastName, new { @class = "form-control" })
    </div>

    <div class="form-group">
        @Html.LabelFor(s => s.StateId)
        @Html.DropDownListFor(s => s.StateId, new SelectList(Model.States, "StateId", "StateAbbr"), "", new { @class = "form-control" })
        @Html.ValidationMessageFor(s => s.StateId)
    </div>

    <div class="form-group">
        @Html.Hidden("hCityId", (object)ViewBag.CityId)
        

Open in new window

0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I have a DataList that has a bunch of controls in it. I load controls based on what is supposed to be shown from my database. I show certain images, buttons, labels based on values, and blablabla....Everything works fine. But......I have buttons that will show up based on logic and they all work but I added the RoundedCorners Extender and I noticed that the rounded corners only happen on the very first DataList item? It shows the first item with rounded corners but not on any of the following buttons? I should note that I only have code for the ItemTemplate( also have minimal code for HeaderTemplate and FooterTemplate) but not for anything else (AlternatingItemTemplate, SelectedItemTemplate, etc...). Im not sure if I have to have code for one of the other Templates in the Datalist for the roundedcorners to work for every item but I tried the AlternatingItemTemplate(?) but that didnt work.
I forgot to add that I am having the same exact problem with the balloonPopupExtender. It works on the first but not on any of the other items in the DataList

If anyone has any suggestions Id really appreciate it. If I cant find something Im just gonna take it out but I really like the look so I would hate to have to do that. Thanks for any help!!

I added a pic just to show what Im dealing with...Thx again

DataList RoundedCorners
0
Hello Experts!

I have a website that uses microsoft.aspnet.Identity for Logging in.  I have a companion windows program that I'd like to be able to create users and make adjustments to the settings of the website.  

Is it possible to Microsoft.aspnet.Identity to create users in a Windows Program or is that only for Web only?
Would anyone have example code?

thanks!
0
public HttpResponseMessage ER_GenerateWBLWorksheet2()
    {

        Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
        Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
        Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
        object misValue = System.Reflection.Missing.Value;

        xlWorkBook = xlApp.Workbooks.Add(misValue);
        xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

        if (xlWorkSheet == null)
        {
            Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct.");
        }

        xlWorkSheet.Cells[1, 1] = "Account Number";
        xlWorkSheet.Cells[1, 2] = "Amount";
        xlWorkSheet.Cells[1, 3] = "Code123";
        xlWorkSheet.Cells[1, 4] = "Date";
        xlWorkSheet.Cells[1, 5] = "Audit";
        xlWorkSheet.Cells[1, 6] = "ID";
        xlWorkSheet.Cells[1, 7] = "Customer Name";
        xlWorkSheet.Cells[1, 8] = "Payment Source";
        Microsoft.Office.Interop.Excel.Range range = xlWorkSheet.get_Range("A2", "A2");//add this drop down list to all rows of first column
        Microsoft.Office.Interop.Excel.DropDowns xlDropDowns;//code to add drop down list
        Microsoft.Office.Interop.Excel.DropDown xlDropDown;
        xlDropDowns = ((Microsoft.Office.Iterop.Excel.DropDowns)(xlWorkBook.ActiveSheet.DropDowns(Type.Missing)));
 …
0
I have a form in  razor view (see sample code below). In the form tag, i have specified controller action method, that will be called when form is posted. I want to validate user input, when user clicks on search button. and if there are any errors in user input, prevent the form posting and display errors.

I can create a javascript/jquery function to check for user input validation. how should i call the this function and how can i prevent the form submission, if there are any errors?


--default.cshtml
 <form id="defaultForm" method="post" action="controllerMethod">

<input type="submit" id="searchBtn" value="Search" />
......
</form>
 <script type="text/javascript">
</script>
1
On my asp.net mvc view page I have textbox like this.

The EventTime field is a DateTime datatype in the database.
I'm using the Entity Framework Database First approach.

On the web browser i'm displaying it like this:  09:00 AM

@Html.TextBoxFor(model => model.EventTime, "{0:hh:mm tt}", new { @class = "form-control", id = "EventTime" })
@Html.ValidationMessageFor(model => model.EventTime)

But the validation is saying "The field EventTime must be a date."


Any ideas of how to fix this?
0
ok here's how I designed my repeater of source...
<td class="col-md-1">
                                <asp:Label ID="lblPersonType" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TYPEDESCRIPTION")%>'></asp:Label>
                            </td>

Id like to get the text property of the lblPersonType in code behind.
Repeater ID=myRepeater
0
Hi Experts,

I want to create a global variable and use it throughout the program.  I am using  "Public Action As String". But it does not work.
What should I do?

Thanks in advance.
0
Hi Guys,
I have aspx page that have textbox controller and listbox controller in my page:
<asp:TextBox ID="txtObject" onfocus="this.select();" runat="server" AutoPostBack="True" CssClass="form-control"></asp:TextBox>
<asp:ListBox Style="border: none; min-height: 350px;" Width="100%" ID="lstTracked" runat="server"></asp:ListBox>

Open in new window


Now, when I type some text on the textbox and enter it is inserting the text to the lstbox and so on, but in some point after I enter 3 4 and sometimes 10 entries I'm getting error:

Here is the error:
Source:      System.Web
Description:      Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Source:      Void ValidateEvent(System.String, System.String)
Data:      at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) at System.Web.UI.WebControls.ListBox.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, …
0
Hi Experts,

Why my code not working?

I have multiple checkboxes and are categoriesed into two parts.

1. Select All (has approx 15-20 checkboxes under it)
2. Release

Scenrio :
Expected : When I click on 'select all' checkbox it should select all the other but except 'release' checkbox.

Not Expected : But in my case the following Code selects all the checkboxes
<script type="text/javascript">
		function checkUncheckAll(theElement) {
			var theForm = theElement.form, z = 0;
			for (z = 0; z < theForm.length; z++) {
			    if (theForm[z].type == 'checkbox' && theForm[z].name != 'ckrelease') {
			        theForm[z].checked = theElement.checked;
			    }
			}
		}
	</script>

Open in new window


<asp:CheckBox ID="ckrelease" runat="server" Text="Release" AutoPostBack="true" TextAlign="Right" OnCheckedChanged="ckRelease_CheckedChanged" />
<input id="Checkbox1" onclick="checkUncheckAll(this);" type="checkbox" tabindex="32" />

Open in new window


Please help.

Regards,
D Patel
0
Free Tool: ZipGrep
LVL 8
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Si,

I've added a quartz timer to my web app and let it run in Application_start (global.asax).

The idea is that the timer sends mails once a day.

Problem now is that application_start is not always active (application pool restarts, no activity).
The website is on a shared hosting platform (IIS). So my options are limited.

Does anyone have an idea how to keep the ASP.NET web app alive so the timer is Always running and the mails are being send?

Thanks!

Kind regards,
Gery
0
Dear Experts,
I am creating an online database portal that requires a user login.  Once logged in, the user has access to various pages, one of them will jump to a payment center of a bank.  (In my case, Union Bank, https://www.hoabankservices.com/Services.aspx)

Is there anyway that I can inject the userID from before jumping to this payment center, and have it automatically show up in User ID box?
Please advise.  Thank you.
0
I have been tasked to build an online audit questionnaire/survey. I am fairly new to asp.net. I want to create the questions and server controls dynamically with data from sql server. For each questions I will need to dynamically create two  (Yes/No) radio buttons. Any help would be greatly appreciated. I am using asp.net forms.
0
Hi Experts,

This is my program. I am using some private variable to hold the values. Then I am using them through out the program. I want to know is it the right way to do or I should keep them in the session variable and use them. I am curious to know that when many people access the same web page are these variables going to create problem or change the values.  I am using ASP.net and VB.net.

Thanks in advance.


Partial Class EditCustomerOrder
    Inherits System.Web.UI.Page
    Private Shared Calling_Form As String
    Private Shared CustomerID As Integer
    Private Shared LocationID As Integer
    Private Shared MenuOrderDate As DateTime
   
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Calling_Form = Request.QueryString("Calling_Form")
       
            If Session("EditCustOrder_Calling_Form") Is Nothing = False Then
                Calling_Form = Session("EditCustOrder_Calling_Form")
            Else
                Calling_Form = Request.QueryString("Calling_Form")
            End If

            If Session("EditCustOrder_MenuOrderDate") Is Nothing = False Then
                MenuOrderDate = Session("EditCustOrder_MenuOrderDate")
            Else
                MenuOrderDate = Request.QueryString("MenuDate")
            End If
0
EgEgI have checkbox that when' Checked' sets the  value of the checkbox into a textarea.

    Protected Sub chkReviewdate_CheckedChanged(sender As Object, e As EventArgs) Handles chkReviewdate.CheckedChanged
        CheckActions()
        txtNotes.Text = "Review date to be added or incorrect"
    End Sub

Open in new window


The problem is that when more than 1 checkbox is checked it overwrites the value in   txtNotes.Text with the latest checkbox value

What I would like to do is list ALL the values of the 'Checked' checkboxes, not just the last one. Whats the best way to achieve this?
0
I need a query using which i can hide the details of Products not selected while shopping..for eg suppose we have 5 products option to buy and we choose only 2 out of 5, is there any sql-query or method(Repeaters,data list..etc) using which we can hide the item details not selected..using asp.net c#
0
Hello all,

I have an asp.net mvc project and I am trying to moq a datatable within a controller like so:

Controller:
public JsonResult LoadCustomerData(string viewName)
{
            var dataRequest = loadDataRequest(viewName);
            DataTable viewData = CustomerDataService.GetData(viewDataRequest);
}

private loadDataRequest(viewName)
{
//loads request here
}

This is a sample to scale down what I have but I tried in a test to do a setup on the CustomerDataService and return a fake datatable I created but when I call the controller the DataTable is = null still.

Thanks
0
I want to add categories but I have this error
Here Is the source code
Line 70:                                            <asp:DataList ID ="dd" runat="server">
Line 71:                                             <ItemTemplate>
Line 72:                                                 <li><a href="#Events.aspx?type=<%#Eval("EventTypeName") %>"><%#Eval("EventTypeName") %></a></li>
Line 73:                                                </ItemTemplate>  
Line 74:                                             </asp:DataList>    

Open in new window

Code behind
 
con.Open();
        SqlCommand cmd = con.CreateCommand();

        if (Request.QueryString["type"] == null)
        {
            cmd.CommandText = "SELECT * FROM EventDetail";
        }
        else
        {
            cmd.CommandText = "SELECT * FROM EventDetail WHERE EventType_ID= '" + Request.QueryString["type"].ToString() + "' ";
        }

        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        dd.DataSource = dt;
        dd.DataBind();
        con.Close();

Open in new window


I have 2 tables
1. Event Type ( EventType_ID, EventTypeName )
2. EventDetail (EventDetail_ID, EventType_ID, eventDetailName....)
0
Hi,

I am looking at a few different things. I am using ASP.NET 4.0 and VB.NET code-behind.

The main situation is this.

I have a page with an iFrame.  We'll call that Page 1 and the page in the iFrame as Page 2. The page of the iFrame on Page 2 is a URL location is external and that page cannot change.

Page 1 is polling the database running on reload of the page which invokes the Page_Load on the reload. That Page_Load is executing the stored procedure to check certain values in a table. Page 2 (the one in the iFrame) is where certain information is entered and will have a submit button. After a period of time, information from the Page 2 will go into the same table that I am polling on Page 1.

What is going on is every time Page1 reloads (based on like 10 second interval) the data in Page 2 (in the IFrame) is lost.

How can I keep that from happening?

I can think of one way, off the cuff, and that is to use the Page 1 and Page 2 as a frameset. And one Frame (for the Page 1) is doing the polling and reloading... The other frame is doing the Page 2 but in an iFrame.

When the user hits the "Submit" button on the second frameset (Page 2) then break out of the frameset and only have the Page 1.

Break out of the Frameset from the code behind of Page2 with JavaScript like? Or is there another way?

Page.RegisterClientScriptBlock("ResetPage", "<SCRIPT>top.location.href=" + Page1URL + "</SCRIPT>");

Open in new window


That is one option. Is there another …
0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I have a web service built with VS 2017 in an ASP.Net website. I need to call that service from a form within an ASP.Net Core website. Is there a way to do this. Ideally, I want a form in the ASP.Net core website that will call the web service when a button is clicked. So far I'm struggling to get something, and there does not seem to be much documentation yet. Thanks for any help.
0
How do you find out in programming ASP.NET pages what version of html is being used?
Is there a setting in Visual Studio?

What trigger my question was I read the following:

The width attribute of <td> is not supported in HTML5. Use CSS instead.
CSS syntax: <td style="width:100px">

https://www.w3schools.com/tags/att_td_width.asp
0
After clicking the type, it still shows all the items!
source code
   <asp:DataList ID ="dd" runat="server">
                                                <ItemTemplate>
                                                <li><a href="#Events.aspx?type=<%#Eval("EventTypeName") %>"><%#Eval("EventTypeName") %></a></li>
                                               </ItemTemplate>
                                            </asp:DataList>

code behind
 con.Open();
        SqlCommand cmd = con.CreateCommand();
        cmd.CommandType = CommandType.Text;

        if (Request.QueryString["type"] == null)
        {
            cmd.CommandText = "select * from EventDetail";
        }
        else
        {
            cmd.CommandText = "select * from EventDetail where EventTypeID= '"+ Request.QueryString["type"].ToString()  + "' ";
        }

        cmd.CommandText = "select * from EventType";
        cmd.ExecuteNonQuery();
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        dd.DataSource = dt;
        dd.DataBind();
        con.Close();

my two tables
1. EventDetail (EventDetail_ID, EventTypeID, eventDetailName, eventDate......)
2. EventType (EventType_ID, EventTypeName)
0
I have a ASP.NET application. I'm using TFS to check in my code.

In my project I revised a few files and then checked them in to tfs.

But after I checked my files in. I noticed the one file that I didn't check in was the Visual Studio .csproj file.

So when I get the latest. The files I checked in are phyiscally there but not included in the application directory.

Is there a way to fix this? So the checked in files are added to the app directory.
0
After I added a sidebar and repositioned my items I had this error!

Codes from the source
            <tr>
                 <td>
                    <div class="col-sm-4">
                         <div class="thumbnail bg-grey text-center">
                             <h2>$14</h2>
                             <p>Basic License</p>
                             <a href="#" class="btn btn-success" role="button">Buy Now</a>
                         </div>
                     </div>  

              <div class="col-sm-8">
                  <asp:Panel  ID="Panel1" runat="server" cssClass="pnlEvents" ></asp:Panel>
             </div>
                 </td>                
             </tr>

My code behind error            

Line 52:
Line 53:                 //Add dynamic Panes to static Parent panel
Line 54:                 pnlEvents.Controls.Add(eventPanel);
Line 55:
Line 56:             }
0
After finally getting assistance with my asp code and compiling so it runs properly on my desktop,  I copied files to hosting server and now I get this message from the server:


Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
0

ASP.NET

123K

Solutions

35

Articles & Videos

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