Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium







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

The following function takes an array of files - all pdf files - to merge into the destination file. The function works so far as the merge goes, but fails to release the file which is copies the relevant pages.

    Public Function MergePdfFiles(ByVal pdfFiles() As String, ByVal outputPath As String) As Boolean
        Dim result As Boolean = False
        Dim pdfCount As Integer = 0                             'total input pdf file count
        Dim f As Integer = 0                                    'pointer to current input pdf file
        Dim fileName As String = String.Empty                   'current input pdf filename
        Dim reader As iTextSharp.text.pdf.PdfReader = Nothing
        Dim pageCount As Integer = 0                            'current input pdf page count
        Dim pdfDoc As iTextSharp.text.Document = Nothing        'the output pdf document
        Dim writer As PdfWriter = Nothing
        Dim cb As PdfContentByte = Nothing
        'Declare a variable to hold the imported pages
        Dim page As PdfImportedPage = Nothing
        Dim rotation As Integer = 0
        'Declare a font to used for the bookmarks
        Dim bookmarkFont As iTextSharp.text.Font = iTextSharp.text.FontFactory.GetFont(iTextSharp.text.FontFactory.HELVETICA, 8, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLUE)


            pdfCount = pdfFiles.Length

            If pdfCount > 1 Then
                'work out the percentage of what 

Open in new window

What does it mean to be "Always On"?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

I have secured classic asp web application and I want
instead of having a link format of:

I want to display, URL format like:

Option 1 hide the .asp extension

or Option 2 replace generic word

or Option 3 replace .aspx in place of .asp
Hey all I am trying to find a good example of how to use the SSRS viewer in my already built asp.net MVC page. And BTW I'm new at using SSRS :)

The code I am working with (controller):
Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.SizeToReportContent = true;
reportViewer.Width = Unit.Percentage(900);
reportViewer.Height = Unit.Percentage(900);

var connectionString = ConfigurationManager.ConnectionStrings["DbEmployeeConnectionString"].ConnectionString;
SqlConnection conx = new SqlConnection(connectionString);
SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM Employee_tbt", conx);  

adp.Fill(ds, ds.Employee_tbt.TableName);
reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\MyReport.rdlc";
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("MyDataSet", ds.Tables[0]));
ViewBag.ReportViewer = reportViewer;

return View();

Open in new window

And the view:
@using ReportViewerForMvc;
    ViewBag.Title = "ReportEmployee";

@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)

Open in new window

But what I am looking to do is have the user create their own query from a dropdown list and have it populate the report that way. It seems the code above is only looking at the Employee_tbt.

How can I modify the code above in order to accept any query string and populate a default .rdlc report file?
I have an account at box.com. Using a browser I can select a file, for example a Powerpoint file, in a folder and click "Open". That will download the file and automatically start Powerpoint. I can then edit the file. When I select "Save" in Powerpoint the file will automatically be saved in my folder at box.com. This is a very neat function.

Now, I would like to build something similar in asp.net. I have files in a folder at the server. Using System.Web.HttpContext.Current.Response.TransmitFile I have been able to create a function that downloads a file but how to automatically start an application than can use the file (for example Powerpoint)?

And how do I create a function that automatically saves that file directly to my server folder from a Windows application (like Powerpoint)?
I just downloaded Oracle.ManagedDataAccess Version( via Nuget Package, and I'm developing using Visual Studio 2013, and the project framework is 4.0

Here is the problem I'm having. I'm able to connect to an Oracle database when I provide information like the host, port, and service name. However, I'm not able to connect when I just use the data source name. In other words....

Data Source=MySOURCE;User Id=MyId;Password=MyPass
-The above works with System.Data.OracleClient
-The above does not work with that Oracle.ManagedDataAccess dll.

The only way I can use the Oracle.ManagedDataAccess.dll is if I do something like this...


Any way to get around this with the Oracle.ManagedDataAccess dll?

This is the error I get....

Oracle.ManagedDataAccess.Client.OracleException: ORA-12154: TNS:could not resolve the connect
identifier specified ---> OracleInternal.Network.NetworkException: ORA-12154: TNS:could not
resolve the connect identifier specified
I have been trying to figure out how to bind sql data to a radCombo box that is nested within a radGrid's automatic Edit Form.
Oddly enough, I was able to figure out how to "cascade" the radCombo boxes Department & ActivityNum as shown in the screenshot.  What I have not figured out is how to initially bind ActivityNum onDataBound.  The exact problem I am having right now is that the following line results in cboActivityID=Nothing resulting in the errors in the screenshots below...

Dim cboActivityID As RadComboBox = e.Item.FindControl("cboActivityNum")

<telerik:RadGrid ID="grdDetail" runat="server" CellSpacing="0" DataSourceID="sqldsDetail" DataKeyNames="TID" GridLines="None" Skin="Telerik" Height="350px" AllowSorting="True" AllowAutomaticUpdates="True" >
            <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
            <Selecting AllowRowSelect="True" />
            <Scrolling UseStaticHeaders="True" AllowScroll="True"/>
            <Resizing AllowColumnResize="True" />
        <MasterTableView AutoGenerateColumns="False" DataSourceID="sqldsDetail" DataKeyNames="TID" EditMode="EditForms" AllowAutomaticUpdates="True">
            <RowIndicatorColumn Visible="true">
            <ExpandCollapseColumn Created="True">

Open in new window

my source code at my details page is like that:
 <asp:Repeater ID="rptrImages" runat="server">
    <div class="item <%# GetActiveClass(0) %>">
       <img src="<%# "data:image;base64," + Convert.ToBase64String((byte[]) Eval("EImage01Byte")) %>"></img>
              <div class="item <%# GetActiveClass(1) %>">
       <img src="<%# "data:image;base64," + Convert.ToBase64String((byte[]) Eval("EImage02Byte")) %>"></img>
 <asp:Repeater ID="rptrEventDetails" runat="server">
            <div class="divDet1">
            <h1 class="proNameView"><%#Eval("EName") %></h1>
            <span class="proOgPriceView"><%#Eval("EPrice") %></span><span class="proPriceDiscountView"> <%# string.Format("{0}", GetDiscount(Convert.ToInt64(Eval("EPrice")) , Convert.ToInt64(Eval("ESelPrice")))) %> OFF</span>
       <p class="proPriceView"><%#Eval("ESelPrice") %></p>
        <div class="divDet1">
             <span class="h5Quantity">Availability: </span><span><%#Eval("EQty") %></span>
             <span><h5 class="h5Size">Quantity: </h5></span><span><asp:TextBox ID="tbQty" runat="server"></asp:TextBox></span>
              <asp:Label ID="l1" class="no" runat="server"></asp:Label> 
              <asp:Label ID="l2" class="no" runat="server"></asp:Label>
            <asp:Button ID="btnAddToCart" 

Open in new window

I'm new to ASP.NET MVC development and I have a question regarding Business Logic.  Specifically, where should the Business Logic live in my application.

Just to give you a bit more information about my current MVC application structure, I've decided to go with a Unit of Work Design Pattern and the Repository Design Pattern for my Data Access Layer.  This was chosen to allow flexibility as the data source may be changing and we want to make the application decoupled from it's original data source.

Here's a business logic scenario I have and I'm questioning where it should live.  

I need to gather information from 3 individual tables in my database, perform some calculation on that data (and in some cases merge some data) and return the matching row(s) to my Controller so that can be displayed in my View.  

In my search to discover where to put this logic I was pointed in several different directions.  For example:

- Your business logic should be placed in the Model, and you should be aiming for fat models.
- Most of your logic goes in the MVC controller
- Controller shouldn't have any logic and should be "thin"
- You should create a "Service Layer" and put your Business Logic there.

I'm lost.  Help.
i want to develop a mvc project with database sql server 2014

i want to make a registration form with fields Id,fullname,email,mobile,age,gender,photo path and photo binary data in database.

user should be able to see his details once registered and could be able to update his details as well as the photo he uploaded

please help me with this as i am new in mvc
Example simplified/contrived for this question. Recently, I came across following code sample.
There is a Js helper file defined as function() JsHelper and there are bunch of other methods created and defined
as JsHelper.prototype.... .

In the view code under document ready function, a new helper is created --> helper = new JsHelper();

My understanding is JsHelper object is created (even though , it is a function but can be used as a object).
and when once created it will execute all the code within the JsFile, is this right?

and also, in the JsHelper function, a variable me is assigned to this? how does it work?

-----------razor view code ------------------
       $(document).ready(function () {
            helper = new JsHelper();

----------JsFile ---------------------
function JsHelper(){
    var me = this;
     meElements = $("#form").find("input");
      me.dosomething ();

JsHelper.prototype.dosomething = function (){
     var me = this;
       $("#div").each( function () {
             //do sth with the elements
Free Tool: Path Explorer
LVL 11
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Im using web service, where the data in project B has to be updated in project A,

Heres how i did for the DAL class in project B
 public DataSet UpdateBook(String baddress, String bpostalcode, String bcountry, String saddress, String spostalcode, String scountry, String bcompany, String bcity, String scompany, String scity)
            int result = 0;
            DataSet updateAdd;
            SqlDataAdapter da;
            string queryStr = "UPDATE CompanyAddress"
                + "SET BillingAddress=@billingaddress, BillingPostalCode=@billingpostalcode, BillingCountry=@billingcountry, ShippingAddress=@shippingaddress, ShippingPostalCode=@shippingpostalcode, ShippingCountry=@scountry, BillingCompany=@billingcompany, BillingCity=@billingcity, ShippingCompany=@shippingcompany, ShippingCity=@shippingcity"
                + "WHERE CompAddressId=@compAddressId";
            SqlConnection conn = new SqlConnection(_connStr);
            updateAdd = new DataSet();
            SqlCommand cmd = new SqlCommand(queryStr, conn);
                da = new SqlDataAdapter(queryStr.ToString(), conn);
                cmd.Parameters.AddWithValue("@billingaddress", baddress);
                cmd.Parameters.AddWithValue("@billingpostalcode", bpostalcode);
                cmd.Parameters.AddWithValue("@billingcountry", bcountry);
                cmd.Parameters.AddWithValue("@shippingaddress", saddress);

Open in new window


I have used ado.net to return a dataset
I now need to query the dataset with linq


int event1Count = ds.where(eventId = 1);
int event2Count = ds.where(eventId = 2);

Open in new window

How can I achieve this ?
I have an ASP.Net MVC web application. I have several views and controllers. How do you change what controller a view is tied too? For example, I created a view that referenced code in the HomeController. I created a new controller to house that code only, but I can't get the view to use the new controller instead of the HomeController. I hope that makes sense. Thanks for any help.
How to bind existing crystal report file (report.prt)  to report viewer in asp.net
thanks in advance
I cannot show the message prompt properly, by the following. Why?

function showMsg0() {
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
    return false;
        protected void userabbr_post_change(object sender, EventArgs e)
            if (tb_userabbr.Text.ToUpper() == "NEW")
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showMsg0()", true);
                tb_userabbr.Text = "";

Open in new window

I'm trying to change the height and width of some divs, at runtime, but I haven't had much luck so far.

this my source code

 <div id="divImgContainer" style="height: auto; width: 1000px; overflow-y: scroll; display: inline" runat="server">

           <div id="divImg" style="height: 900px; width: 640px; overflow: auto; float: left;" runat="server">

               <asp:UpdatePanel runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional" ID="upnlMainImage">
                       <asp:Image runat="server" ID="img"
                           Height="900px" Width="640px" BorderStyle="Solid" BorderWidth="2px" BorderColor="Red"></asp:Image>

           <div id="divResult" style="float: left;" runat="server">
               <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="upnlTicks" ChildrenAsTriggers="False">
                       <asp:Panel ID="pnlResult" runat="server" Height="900px" GroupingText="Mark Here" Width="320px">
                           <asp:Label ID="lblResults" runat="server" Text=""></asp:Label>
                           <asp:Repeater ID="rptResults" runat="server" OnItemCommand="rptResults_ItemCommand" OnItemDataBound="rptResults_ItemDataBound">

Open in new window

Hi, I'm changing the class at runtime of a table (tblzoom) which is inside a repeater. However the changes are not kept after postbacks.
 <div id="divImgContainer" style="height: auto; width: 1000px; overflow-y: scroll; display: inline">

           <div id="divImg" style="height: 900px; width: 640px; overflow: auto; float: left;">

               <asp:UpdatePanel runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional" ID="upnlMainImage">
                       <asp:Image runat="server" ID="img"
                           Height="900px" Width="640px" BorderStyle="Solid" BorderWidth="2px" BorderColor="Red"></asp:Image>

           <div id="divResult style="float: left;">
               <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="upnlResults" ChildrenAsTriggers="False">
                       <asp:Panel ID="pnlResult" runat="server" Height="900px" GroupingText="Mark Here" Width="320px">
                           <asp:Label ID="lblResults" runat="server" Text=""></asp:Label>
                           <asp:Repeater ID="rptResults" runat="server" OnItemCommand="rptResults_ItemCommand" OnItemDataBound="rptResults_ItemDataBound">
                                   <table class="nozoom" id="tblzoom" 

Open in new window


I am looking for a Microsoft Cloud accounting system for a small operation.
I need to be able to send data to the accounting system from an ASP.net web app.
Is this possible with Microsoft Dynamics?
If not is there a better option?
I am trying to follow some instructions on how to send an email with sendgrid but I cant get it to work.

I have setup an azure account and got an api key. Then I cant get it to work to send the mail.  This is the code where it should be include the right stuff.

In my web.config I have added the api key. SO what should go into the

 public class EmailService : IIdentityMessageService
        public Task SendAsync(IdentityMessage message)

        // Plug in your email service here to send an email.
        return Task.FromResult(0);

Open in new window

Industry Leaders: We Want Your Opinion!
Industry Leaders: 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!

With inspiration from https://ppolyzos.com/2016/09/09/asp-net-core-render-view-to-string/ I tried to make an service to render Razor pages to a string.

It seems like page.ViewContext.View is empty and results in a nullreferenceexception. How do i fix this?

var result = await _pageRenderService.RenderPageToStringAsync("Index", viewModel);

Open in new window

The service:
   public interface IPageRenderService
        Task<string> RenderPageToStringAsync(string pageName, object model);
    public class PageRenderService : IPageRenderService
        private readonly IRazorViewEngine _razorViewEngine;
        private readonly ITempDataProvider _tempDataProvider;
        private readonly IServiceProvider _serviceProvider;
		private readonly IHttpContextAccessor _httpContext;
		private readonly IActionContextAccessor _actionContext;
        public PageRenderService(
			IRazorViewEngine razorViewEngine,
            ITempDataProvider tempDataProvider,
            IServiceProvider serviceProvider,
			IHttpContextAccessor httpContext,
			IActionContextAccessor actionContext
            _razorViewEngine = razorViewEngine;
            _tempDataProvider = tempDataProvider;
            _serviceProvider = serviceProvider;
			_httpContext = httpContext;
			_actionContext = actionContext;
		public async Task<string> RenderPageToStringAsync(string pageName, object model)
			var tempData = new 

Open in new window

Dear Experts,
Please suggest how to set tab indexing for asp .net input controls in asp.net
seeing weird characters from webresponse for bootstrap contents. results expected as this image expected.png, but all i see is below image
Can someone tell me where is the ASP.NET Core Web Application template?
It's there for C# but is missing for VB.NET
good afternoon,
I was wondering if it is posible to use operators like OR/AND as follow in asp.net

 if (_context.User.Any(ac => ac.Id.Equals(23) && ac.Active.Equals(1)))

Open in new window

or what is the right way of doing something similar to that.

I appreciate your help thanks.
After my category drop down list is selected, it is supposed to show the sub categories of that particular category. However there is an error now!
Below is the code, the commented codes are what worked initially, however now i have to use BllSubCategory, which caused the error to occur
     protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
            int MainCategoryID = Convert.ToInt32(ddlCategory.SelectedItem.Value);
            BllSubCategory subCat = new BllSubCategory();
            DataSet ds = subCat.GetSubCatByCatName();
            ddlSubCategory.DataSource = ds;
            ddlSubCategory.DataTextField = "SubCatName";
            ddlSubCategory.DataValueField = "SubCatID";
            ddlSubCategory.Items.Insert(0, new ListItem("-Select-", "0"));
            ddlSubCategory.Enabled = true;
            /*  int MainCategoryID = Convert.ToInt32(ddlCategory.SelectedItem.Value);
             *  using (SqlConnection con = new SqlConnection(CS))
                  SqlCommand cmd = new SqlCommand("select * from tblSubCategories where MainCatID='" + ddlCategory.SelectedItem.Value + "'", con);
                  SqlDataAdapter sda = new SqlDataAdapter(cmd);
                  DataTable dt = new DataTable();

                  if (dt.Rows.Count != 0)

Open in new window







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