ASP.NETSponsored by Jamf Now

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 have ASP.NET web forms application, with master page and lot of user control (ascx)  for menus and Tabs. I want to make the site responsive with bootstrap. I am new to bootstrap. I see newer with newer version of asp.net and visual studio, when i create a new web forms project , the master page already has bootstrap implemented as such

<div class="navbar navbar-inverse>
   <div class = "container">
     ......
           <footer>
     .......

and so on.

can I copy this html layout, directly into my old application ? I'm not sure if tags like <footer><footer> will work? is this html5 element or something related to bootstrap?

also in my old application, I have user controls (ascx) file for navigation, like shown below

<form>
      <usercontrol:navigationMenu>
      <asp:contentPlaceholder id="content" runat =server>
</form>

what would be best approach, to converting to bootstrap.
0
Cloud Class® Course: Microsoft Windows 7 Basic
LVL 12
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

How to get currency exchange rate in ASP.NET C#  webform .
I've using the following answer but doesn't work.
Expert Exchange Solution

Maybe google currency converter not exist. is there any other way.
aaa.PNG
0
Hi

In my ASP.net web app I populate a data table called "dt" then bind it to my GridView.

I then using the following code to filter the data. The problem is that the data keeps shrinking as though the previous filter is still there
when running the code. What am I doing wrong?

  Protected Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnFilter.Click
        Try
            Me.GridView1.DataSource = dt
            Dim oDataView As DataView = dt.DefaultView
            Dim F As String = ""
            If Len(Me.txtID.Text) > 0 Then
                F = "ID = " & Me.txtID.Text
            End If
            If Len(Me.txtType.Text) > 0 Then
                If F <> "" Then F = F & " And "
                F = F & "Type = '" & Me.txtType.Text & "'"
            End If
            If Len(Me.txtRef.Text) > 0 Then
                If F <> "" Then F = F & " And "
                F = "Ref = '" & Me.txtRef.Text & "'"
            End If
            If Len(Me.txtCategory.Text) > 0 Then
                If F <> "" Then F = F & " And "
                F = "Category = '" & Me.txtCategory.Text & "'"
            End If
            If Len(Me.txtWidth.Text) > 0 Then
                If F <> "" Then F = F & " And "
                F = "Width = '" & Me.txtWidth.Text & "'"
            End If
            If Len(Me.txtLength.Text) > 0 Then
                If F <> "" Then F = F & " And "
                F = "Length = '" & Me.txtLength.Text & "'"
            End If
            

Open in new window

0
ASP.NET C#
Visual Studio 2017

Description:
example of form
I am creating a form where the user clicks an image (image has runat='server' attribute), and then uploads a new image that replaces the old image.
( Note: that when the user uploads a new image it is renamed to exactly the same name as the old image. )

I'm using a hidden Fileupload control for uploading images.

Problem:
Initially ( when I upload the first version of the image ) everything works fine, but once I start uploading new images ( to replace the old ones ) I start getting the error:

System.IO.IOException: The process cannot access the file 'filename' because it is being used by another process.

Code Sample:
I do some validation checks and then something like:

try
{
    fileUpload.PostedFile.SaveAs(path);
}
catch (Exception ex)
{
     lblMessage.InnerText = ex.ToString();
}
finally
{
    fileUpload.Dispose();
}

Open in new window



I tried adding this to see if it works but I still have the same issue:
private void SaveFile(FileUpload fileupload, string path)
        {
            fileupload.PostedFile.SaveAs(path);
            const int numberOfRetries = 10;
            const int delayOnRetry = 1000;

            for (int i = 1; i <= numberOfRetries; ++i)
            {
                try
                {
                    fileupload.PostedFile.SaveAs(path);
                    break; 
                }
                catch (IOException e) when (i <= numberOfRetries)
                {
                    Thread.Sleep(delayOnRetry);
                }
            }
        }

Open in new window


I've also tried toggling images to see if that helps.  For example: If the current image is xxxxa.jpg then save as xxxxb.jpg.  But I still get the same error message.

Final Notes:
I am able to upload images but it seems to be random, sometimes it works and sometimes ( often ) I get the error message.  I've tested the same code on my desktop and everything works great but when I put it on the live server I start seeing the error message.
0
I need to  export from .NET to Excel .
I need place 5 tables to to the same Excel sheet.
I use this code

 private void eResponsetable(DataTable dt, string ReportName, HttpResponse response)
        {


            StringWriter stringWriter2 = new StringWriter();
            HtmlTextWriter htmlWrite2 = new HtmlTextWriter(stringWriter2);

            //this is the grid that will be output to excel
            GridView tempGrid2 = new GridView();
            tempGrid2.Caption = ReportName;
           
            tempGrid2.EmptyDataText = " ";
            tempGrid2.DataSource = dt;
            tempGrid2.DataBind();
            tempGrid2.GridLines = GridLines.Both;
            tempGrid2.HeaderStyle.Font.Bold = true;
           // tempGrid2.HeaderStyle.Font.Size = FontUnit.Large;



           tempGrid2.HeaderStyle.ForeColor = Color.White;
            tempGrid2.HeaderStyle.BackColor = Color.Gray;

            //tell the gridview to render itself to our htmltextwriter
            tempGrid2.RenderControl(htmlWrite2);
            response.Write(stringWriter2.ToString());
        }

  protected void CreateAllReports2()
        {
            HttpResponse response = HttpContext.Current.Response;
            //clean up the response.object
            response.Clear();
            response.ClearContent();
            response.ClearHeaders();
            response.Charset = string.Empty;
            bool inline = true;

            //set the …
0
How to convert Excel file into Data table with formatted columns in VB.NET.

I have Excel File in my desktop. i just want to convert as data table.

The thing is, i don't want same column name which is been specified in the excel file.

i want some corrected and newly defined column name (Formatted Column) .

for example, i have excel column like "Turn Date [S1]" ==> my data table column name is only "TurnDate"

How to do this...?

Attached screen shot for reference.
0
Hi,

I have code written in asp.net and c#. Please let me know how to convert the code into classic asp and vb? I need to display the Logon_user and last visited date and time. I am storing the datetime in database.

Default.aspx

<asp:Label id="username" runat="server"><br>
<asp:Label id="lastvisited" runat="server">


Default.aspx.cs

Protected void PAge_load
{
username = GetUserName();
lastvisited = (string) Session["LastVisitedDateTime"];

}

public string GetUserName()
{
string sUserName = Request.ServerVariables["LOGON_USER"]
sUserName = sUserName.Substring(sUserName.Indexof("\\") + 1);
return sUserName;
}

Global.asax.cs
protected void Session_start(object sender, EventArgs e)
{
string sUserName = GetUserName();
string sDateTime= DateTime.Now.ToString();
Session["LastVisitedDateTime"] = "";
if(sUserName != "")
{
Session["LastVisitedDateTime"] = GetLAstVisitedDateTime(sUserName);
}
UpdateLastVisitedDateTime(sUserName, sDateTime);
}


}

private string GetLAstVisitedDateTime(string sUserName)
{
SqlDataReader myDataReader;

String sLastVisited = "";
myDataReader = GetLastVisitedDateTime(sUserNAme);
while myDataReader.Read()_)
{
sLastVisited = mydatareader.getstring(mydatareader.getordinal("LastVisitedDateTime"));
}

return sLastVisited;
}

private void UpdateLastVisitedDateTime(string sUserName, string sDateTime)
{
SqlConnection objcon = new SqlConnection(connstring);
SqlCommand cmd = new SqlCommand("proc", objconn);
cmd.CommandType = 

Open in new window

0
Hi

In my ASP.net web app I am trying to get the text of the menu item I selected in the following code but it isn't working

 Protected Sub Menu1_MenuItemClick(sender As Object, e As MenuEventArgs) Handles Menu1.MenuItemClick
        Try

            Dim oLevel As Integer = Me.Menu1.SelectedItem.Depth
            Dim oSelectedItemText As String = Me.Menu1.SelectedItem.Text
            Dim oParentItem As MenuItem = Me.Menu1.SelectedItem.Parent
            Dim oParentItemText As String = oParentItem.Text 'This does not work

        Catch ex As Exception
            Response.Write(ex.Message & " pp54")
        End Try
    End Sub

Open in new window

0
Hi

I am using the following html on my ASP.net to try to float two link buttons to the left nd two to the right. The CSS is shown further down. The problem is that the controls that shouls appear on the right area appearing underneath

            <asp:Panel ID="Panel_Menu" runat="server">

                <div class="entire-thing">
                <div class="ad-left">
                            <asp:LinkButton ID="LinkButton2" runat="server" PostBackUrl="~/Default.aspx">HOME</asp:LinkButton>
                &nbsp;
                <asp:LinkButton ID="LinkButton3" runat="server" PostBackUrl="~/Checkout.aspx">CHECKOUT</asp:LinkButton>
                </div>
                <div class="ad-right">
                              <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/Checkout.aspx" Visible="False"></asp:LinkButton>
                <asp:ImageButton ID="ImageButton1" runat="server" Height="23px" ImageUrl="~/Resources/Basket.jpg" PostBackUrl="~/Checkout.aspx" Visible="False" Width="34px" />
                </div>
                <div class="clear"></div>
                </div>
            </asp:Panel>

Open in new window


.ad-left {
    float: left;
    width: 49%;
}

.ad-right {
    float: right;
    width: 49%;
}

.entire-thing {
    width: 100%;
}

Open in new window

0
Hi

I am using the following markup and vb.net code to run when the text in a GridView template TextBox field is
changed. The problem I have with is that the user needs to leave the TextBox for it to run. Is there a way to use some other
event like the mouse up to fire this code?

        <asp:TemplateField HeaderText="Order Qty" >
                               <ItemTemplate>
                                <asp:TextBox AutoPostBack="true" OnTextChanged="OnTextChanged"  ID="txtOrderQty" runat="server" Text='' Width="80"></asp:TextBox>
                                </ItemTemplate> 
                        </asp:TemplateField>

Open in new window


Protected Sub OnTextChanged(ByVal sender As Object, ByVal e As EventArgs)

        'ClientScript.RegisterClientScriptBlock([GetType](), "alert", "alert('" & (TryCast(sender, TextBox)).Text & "');", True)

        Dim tb As TextBox = DirectCast(sender, TextBox)
        Dim row As GridViewRow = DirectCast(tb.Parent.Parent, GridViewRow)
        Dim idx As Integer = row.RowIndex

    End Sub

Open in new window

0
Free Tool: Site Down Detector
LVL 12
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Hi

Is it possible to have a line break in an ASP.net GridView cell that is bound to SQL data?
0
Hi, I've got an ASP.NET project which includes a report (main.rdlc). This report has a sub-report (mySubReport.rldc). Both are set as embedded resources in their properties.
The report runs fine but the subreport does not show up. It comes with the message, on the report itself:


The subreport 'subreport1' could not be found at the specific location /Project_Name Reports/mySubReport. Please verify that the subreport has been published and the name is correct.

Also, when I check the outputwindow I can see the following warning:


Warning: An error occurred while executing the subreport 'Subreport1' (Instance: 0): The report definition for report 'mySubReport' has not been specified (rsErrorExecutingSubreport)



  protected void btnReport_Click(object sender, EventArgs e)
        {
            Warning[] warnings;
            string[] streamIds;
            string mimeType = string.Empty;
            string encoding = string.Empty;
            string extension = string.Empty;

           

            var cnn = new SqlConnection(Global.conString);

            ReportViewer viewer = new ReportViewer();
            viewer.ProcessingMode = ProcessingMode.Local;
  
            viewer.LocalReport.ReportPath = "Reports/Main.rdlc";
            viewer.LocalReport.EnableExternalImages = true;

            
            // viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(addsubreport);

           
 	     

Open in new window

0
We have some international data....city or state...that we get from our customer when they call our API. We save the data in our database.

Some examples:
1. A city in Germany comes as Dülmen This probably should've been Dülmen
2. A State, maybe in Romania, comes as Constan¿a Probably should be Constanţa

These are the only two I see so far. My manager asked me "Please have a look to ensure we are handling the character format correctly upon receipt of data"

How would I do that? how would I know what Dülmen or Constan¿a should be?

The fields in the database are nvarchar(256)
0
Hi

I have a template field text box in my ASP.net GridView. I have managed to trigger
the VB.net code when the text in the GridView text box is changed. How do get the GridView
RowIndex and the text value? Also this code only triggers once you move out of the text box.
Is there a way to trigger it without having to do this?


               Protected Sub OnTextChanged(ByVal sender As Object, ByVal e As EventArgs)
        ClientScript.RegisterClientScriptBlock([GetType](), "alert", "alert('" & (TryCast(sender, TextBox)).Text & "');", True)

        Dim S As String
        Dim oRowIndex As Integer

        Try

        Catch ex As Exception

        End Try

    End Sub

Open in new window


1
0
Hi

In my ASP.net web app I am writing code that loops through a GridView and inserts data into a SQL table.
I want to prevent duplicates based o two columns [Username] and [Item ID].

What I the best way to do this?
0
Hi

I am designing an online SQL database for ordering products on my ASP.net web app.
I am trying to work out the best way to handle the "Basket".
The easiest way in my mind would be to retain the IDs of the items that
a user selects using cookies so that if the user leaves the page and comes
back I can use the cookies to show which items were selected.

An alternative option would be to have a SQL table that is structured
like my Products table. I would insert the user's selected items into this table.

I could also use my Orders table and show the Order status as being in the basket.


I'm looking for a little feedback on this. Thanks
0
I want to create a multi select dropdown list with checkboxes using asp.net and vb.net.
Once the items are selected I want to update a database and send the selected items
to outlook mailbox.

Any suggestions.  I can also use jquery in my project.

Thanks in advance,
Isaac
0
Hi experts,

I saw this example on Grouping with linq.
https://ole.michelsen.dk/blog/grouping-data-with-linq-and-mvc.html

I also saw this example.
https://stackoverflow.com/questions/1160420/how-do-i-group-data-in-an-asp-net-mvc-view

I have a ASP.NET MVC application using C# , Razor and Entity Framework, database first model.

I'm using the Orders table from the Northwind database.

My application directory looks likes this:

AppDirectory.PNG
My controller looks like this:

Controller.PNG
My view looks like this:

View.PNG
When I run my app it shows the Orders table.

Run.PNG
Now I want to Group it by Customer ID.

I looked at this example to try to group my example but I'm having a hard time grouping it.
https://ole.michelsen.dk/blog/grouping-data-with-linq-and-mvc.html

How do I revise my example so it groups by CustomerID.
So my View should look like this:

DesiredSort.PNG

This is my current code for my Controller:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using NorthwindApp.Models;

namespace NorthwindApp.Controllers
{
    public class HomeController : Controller
    {
        private NorthwindEntities db = new NorthwindEntities();

        // GET: /Home/
        public ActionResult Index()
        {
            

            // Order by 

Open in new window

0
I wonder if this is because of IIS and how the site is setup

1. My coworker set up an IIS site like this

image
2. You see there's a path assets-->pages-->img-->login the images in this path aren't showing up. I've tried
/assets/pages/img/login/bg1.jpg,
../assets/pages/img/login/bg1.jpg
~/assets/pages/img/login/bg1.jpg

3. Images under this folder show up "img". This is in the root folder of that "Demo" site. In the image above, I've marked the folder with XX. I have it like this ~/img/CSI-logo.png

When I look at Chrome's console, that path is translated to this (has "demo" in the beginning of it)
2.png
4. If I hard code the "demo" root folder, then the image shows up /Demo/assets/pages/img/login/bg1.jpg

Why is this?  I don't want to hardcode /Demo/ How can I fix this? what path do I need to use?
0
Upgrade your Question Security!
LVL 12
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

I'm working on some convoluted code (developer got frustrated by his own code and left a few months ago!)

1. I get a date string like this {"Year":2017,"Month":9,"Day":30}

2. I want to get the date of out it and concat it ...so 2017/09/30

I want to do it in this routine the developer has. I have to put in a quick fix

 public static DateTime? TryParseStringToDate(string data)
        {
            DateTime date;

           //*** here... parse it here, get 2017/09/30 

            if (DateTime.TryParse(data, out date))
                return date;

            return null;
        }

Open in new window

0
I bought this template and this is the front page

https://keenthemes.com/preview/metronic/theme/admin_4/page_user_login_5.html

I replaced the images in my project but the images are too bright. I was looking at some sites and there's a way to apply a background color to make the images a little bit darker.

I looked at our own company website and they've darkened the images with this CSS. I don't think I need all that. The key is "background". How can I apply it to the site? where does it go? if I know where I can put it, then I can make the change in my code.


body .page #hero .inner-wrap {
  background: rgba(9, 9, 9, 0.6);
  padding: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  max-height: 700px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
}

Open in new window

0
Hi, I am writing ASP.NET Web API to run on Windows/Azure.
What .Net Framework would you prefer 4.* or Core?

Thanks.
0
Hi Experts,

Party politics and partly the other dev doesn't want to change the data format he is sending I've been left with this problem.

I have an integer made up of 3 parts for example: 131110 I need to display this as 13:11:10.

How do I efficiently split this using asp.net VB.

This is further complicated by having to drop any leading zeros so:

90807 needs to show as 9:8:7 (the data width is 6, so assuming the left most digit to be 09)
081207 shows as 8:12:7
etc

Can anyone point me in the right direction please.

Andy
0
Experts,

I have an asp.net application that has a reportviewer embedded in an aspx page. When I run it locally through visual studio it works fine. When I deploy the application to my app server and run it, the reportviewer gives me the following error:

The permissions granted to user 'domain\appservername$' are insufficient for performing this operation. (rsAccessDenied)

The report viewer isn't picking up my credentials and instead is getting those of the app server. I'm using windows authentication on my site.

Anyone help getting to the bottom of this will be much appreciated.

Regards,
0
Hi experts,

I have a asp.net mvc 5 application using C#, Razor, jquery.

This is a followup to this ticket:
https://www.experts-exchange.com/questions/29104238/hyperlink-in-ASP-NET-using-Razor.html?anchor=a42592893¬ificationFollowed=208651180#a42592893

in my view on my table my link is set like this it works fine:

<a id="ReportLink" target="_blank" href="http://google.com/employeeid=@item.EmployeeID">@Html.DisplayFor(modelItem => item.EmployeeID)</a>

Because on click i want user to got to
http://google.com/employeeid=1
http://google.com/employeeid=2
http://google.com/employeeid=3


<a id="ReportLink" target="_blank" href="http://google.com/employeeid=@item.EmployeeID">@Html.DisplayFor(modelItem => item.EmployeeID)</a>

Is there a way to set the href attribute to

Having a Javascript variable called firstpartofhref = "http://google.com/employeeid=" and then set it in the href before the @razor tag something like this?

 href=" firstpartofhref + @item.EmployeeID"

Or
can i just store this razor tag @item.EmployeeID in a javascript variable called secondpartofhref also?

and then set the href attribute something like this?

 href=" firstpartofhref + secondpartofhref"
0

ASP.NETSponsored by Jamf Now

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