ASP.NET

125K

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

Hi. I am using the following VB.net code to convert html in my ASP.net Panel to  a string.
 I then email the result in the body of an email. The problem is that this can be edited.
Can someone suggest a way to make it UNEDITABLE

1:    Protected Sub btnConvertHTML_Click(sender As Object, e As EventArgs) Handles btnConvertHTML.Click
2:        Dim H As String = ""
3:        H = ConvertToHTML()
4:        Me.Label_UsedToTestHtml.Text = H
5:    End Sub
6:
7:    Private Function ConvertToHTML() As String
8:        Dim sb As StringBuilder = New StringBuilder()
9:        Dim tw As StringWriter = New StringWriter(sb)
10:        Dim hw As HtmlTextWriter = New HtmlTextWriter(tw)
11:        Panel1.RenderControl(hw)
12:        Dim html = sb.ToString()
13:        Return html
14:    End Function



Select all
 
Open in new window

1:    Public Function xSendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String,
2:                             ByVal cc As String, ByVal subject As String, ByVal body As String,
3:                             ByVal blnUseHTML As Boolean) As String
4:        Try
5:
6:            ' Instantiate a new instance of MailMessage
7:            Dim mMailMessage As New MailMessage()
8:
9:            ' Set the sender address of the mail message
10:            mMailMessage.From = New MailAddress(from)
11:            ' Set the recepient address of the mail message
12:            mMailMessage.To.Add(New …
0
Hi. I am using the following VB.net code to convert html in my ASP.net Panel to  a string.
I then email the result in the body of an email. The problem is that this can be edited.
Is it possibe to rather convert the html into an image and rather email that as the body of the email?

    Protected Sub btnConvertHTML_Click(sender As Object, e As EventArgs) Handles btnConvertHTML.Click
        Dim H As String = ""
        H = ConvertToHTML()
        Me.Label_UsedToTestHtml.Text = H
    End Sub

    Private Function ConvertToHTML() As String
        Dim sb As StringBuilder = New StringBuilder()
        Dim tw As StringWriter = New StringWriter(sb)
        Dim hw As HtmlTextWriter = New HtmlTextWriter(tw)
        Panel1.RenderControl(hw)
        Dim html = sb.ToString()
        Return html
    End Function

Open in new window


    Public Function xSendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String,
                             ByVal cc As String, ByVal subject As String, ByVal body As String,
                             ByVal blnUseHTML As Boolean) As String
        Try

            ' Instantiate a new instance of MailMessage
            Dim mMailMessage As New MailMessage()

            ' Set the sender address of the mail message
            mMailMessage.From = New MailAddress(from)
            ' Set the recepient address of the mail message
            mMailMessage.To.Add(New MailAddress(recepient))

            ' Check if the bcc value 

Open in new window

0
Hi

In ASP.net VB.net I am sending an email with html embedded in the body.
Is it possible to include something in that html that if clicked on will print the
body of the message?
0
Hi

In my ASP.net web app I am using the following code to convert all the html in a panel
into a string that I then email. It works well  except for the image. How do I include an image in this sort of convdersion?
I have put the markup for the panel below

    Private Function ConvertToHTML() As String
        Dim sb As StringBuilder = New StringBuilder()
        Dim tw As StringWriter = New StringWriter(sb)
        Dim hw As HtmlTextWriter = New HtmlTextWriter(tw)
        Panel1.RenderControl(hw)
        Dim html = sb.ToString()
        Return html
    End Function

Open in new window


        <asp:Panel ID="Panel1" runat="server" Height="520px">
            
                <table>
                    <tr>
                        <td><asp:Label ID="lblBuyerCompanyName" runat="server" Font-Size="X-Large"></asp:Label></td>
                        <td></td>
                        <td><asp:Label ID="lblSpacer" runat="server" Width="100px"></asp:Label></td>
                        <td><asp:Label ID="Label21" runat="server" Font-Bold="True" Text="PURCHASE ORDER" Font-Size="X-Large"></asp:Label></td>           
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td><asp:Image ID="Image1" runat="server" Height="110px" Width="209px" /></td>
                        <td></td>
                        <td></td>
                        <td></td>
        

Open in new window

0
Hi. I want to use the type of VB.net code below to contruct the Purchase Order shown further on. This is for the body of an email.
As you can see I have used an html table for spacing. How should I approach this? Is there perhaps a better way to do this without a table?

            Dim oHBody As String = ""
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor1 & " name = 'Calibri'>" & oIntro & "</font></body></html>"
            oHBody = oHBody & "<br>"
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor2 & " name = 'Calibri'>" & sDate & "</font></body></html>"
            oHBody = oHBody & "<br>"

Open in new window


Design View
   <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblBuyerCompanyName" runat="server" Font-Size="X-Large"></asp:Label>
                        </td>
                        <td></td>
                         <td>
                             <asp:Label ID="lblSpacer" runat="server" Width="100px"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="Label21" runat="server" Font-Bold="True" Text="PURCHASE ORDER" Font-Size="X-Large"></asp:Label>
                        </td>
                   
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                       <tr>
                        <td>

Open in new window

0
I have a windows form with an OLE control based on the class shell explorer 1. Whilst navigation to a selected web page works and the page is displayed all pages I navigate to result in a script error message. See attached
scripterror.jpg
0
Hi

In my ASP.net VB.net code the third line causes an error "Thread was being aborted". What does this mean?

               Session("oMessageFromEmail") = oUsername
               Session("oMessageToEmail") = xSellerUsername
               Response.Redirect("Message")

Open in new window

0
Hi

In Visual Studio ASP.net what is the difference between Debug and Release mode?

Thanks
0
Hi

In my ASP.net web app the following code is causing an error that for some reason the error handling
code is not trapping. Also the rest of the code doesn't in the procedure does not run
                    Try
                        Session("oMessageToEmail") = xSellerUsername
                    Catch ex As Exception
                        Response.Write(ex.Message)
                    End Try

Open in new window

0
Hi

I used Nuget packages for the first time while trialing PDF converters in ASP.net.
I didn't find any that worked in the way I needed them to. I uninstalled them but am getting strange errors in my project.
I noticed that there where still folcders in the AppData folder. I removed all of these.
How do I completely remove all files relating to these Nuget packages?

Thanks
0
Hi

I have the following ASP.net GridView button. On other pages it work but for some reason it isn't firing on this one page
I have included my markup and VB.net below

           <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False">
                    
                     
                     <Columns>
             
                 <asp:TemplateField HeaderText="?" ControlStyle-Forecolor ="Gray">
                    <ItemTemplate>
                        <asp:Button ID="ButtonQuestion" OnClientClick="showLoading();" runat="server" 
                        CommandName="btnQuestion" 
                        CommandArgument="<%# CType(Container, GridViewRow).RowIndex %>"
                        Text="?" />
                    </ItemTemplate>
                    <ControlStyle ForeColor="#468499" />
                </asp:TemplateField>

Open in new window


            ElseIf (e.CommandName = "btnQuestion") Then

                ' Retrieve the row index stored in the CommandArgument property.
                Dim index As Integer = Convert.ToInt32(e.CommandArgument)
                ' Retrieve the row that contains the button 
                ' from the Rows collection.
                Dim row As GridViewRow = GridView1.Rows(index)

                If IsPostBack Then

                    Dim lblItemID As Label = CType(row.FindControl("lblItemID"), Label)
                    Dim lblOrderQty As Label = 

Open in new window

0
Hi

I just added IronPDF software to my ASP.net web app using NuGet https://www.nuget.org/packages/IronPdf/

I did this so that I could convert a web form to a pdf doc. It works when I run in debug mode but causes errors
after I have published.

What am I missing in the publish. Should I have published certain folders in addition to to the usual publish?

Thanks
0
Can you reference a asp tag that is passed in variable.  I have a table  that contains rows which
contain asp id's example aspTagName = txtFirstName,  fielRequired = false

I want to look at the column fieldRequired and based on value of false
remove the attribute required from the asp page using the value of
the aspTagName(txtFirstName)

Please advise.

Thanks in advance
0
In ASP.net is it possible to convert a text box to a label using code
0
Hi

In my ASP.net web app I want to send an invoice embedded in the body of an email. At the moment I am sending certain
emails using the code  below. That works well for formatted text. Constructing an invoice that has everything
in the right place is a bit more tricky. I am looking for a few pointers on how to achieve this. Thanks

            Dim oHBody As String = ""
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor1 & " name = 'Calibri'>" & oIntro & "</font></body></html>"
            oHBody = oHBody & "<br>"
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor2 & " name = 'Calibri'>" & sDate & "</font></body></html>"
            oHBody = oHBody & "<br>"

Open in new window

0
Hi

In ASP.net I want a user to push a button on a website that runs code that sends the
web page as a pdf attachment, What VB.net code would I use to do this?
0
Hi

I have developed an ASP.net web app in Visual Studio 2017 that does not work properly when I publish it to servers. My hosting company sent me the following message. How do I compile my web app in medium trust

"We have enabled the error reporting for the website via the web.config file. The site now displays an error which indicated that the website is compiled in full trust. However, our servers only allow medium trust.
​Kindly recompile your website in medium trust in order for it to display on our servers."
0
I am getting an error on a page that uses entity and Telerik for a webforms application that uses .net 4.0 because I am not able to update to later version of .net.  Had a different error when trying to use entity framework 6.0 and went down to 5.0 and that error is gone and site loads but now the page I am trying to add has this issue.  See errors below when page is brought up.  Not sure how to see LoaderExceptions when on a server.  No problems running on development computer with Visual Studio 2017.

 Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Open in new window


Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
   System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
   

Open in new window

0
Hi
I have been building ASP.net web apps for a few years now. I used to publish to a windows folder using Visual Studio 2010 and then ftp
the files to the host server. I tried that with Visual Studio 2017 and got errors on the site. Has something changed. Is there
something extra that needs to be done in Visual Studio 2017?
Thanks
0
i have a html text box which allow user to select mulitple states. e.g. the textbox value will be CA,TX,FL

and I want to take the value and turn into like below.

select * from state where statecode in ('CA','TX','FL')

I use c# asp.net web form. please show me how to do that...thanks
0
I am getting a "SqlException: Cannot insert explicit value for identity column in table 'Group' when IDENTITY_INSERT is set to OFF." but I'm not trying to insert identity.

SQL TABLE
CREATE TABLE [dbo].[Group](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Inactive] [bit] NOT NULL,
 CONSTRAINT [PK_Group] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

Open in new window


ASP.NET CORE 2.2 using Razor Pages Code
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace TESCore.Data.Models.Abstract
{
    public abstract class PKEntity : BaseEntity
    {
        [Key]
        public abstract int Id { get; set; }
    }
}

Open in new window


using System;
using System.Collections.Generic;
using System.Text;

namespace TESCore.Data.Models.Abstract
{
    public abstract class PKActiveEntity : PKEntity
    {
        public abstract bool Inactive { get; set; }
    }
}

Open in new window


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using TESCore.Data.Models.Abstract;

namespace TESCore.Data.Models
{
    public partial class Group : PKActiveEntity
    {
        public Group()
        {
            PersonEmployees = new HashSet<PersonEmployee>();
            TimeCards = new HashSet<TimeCard>();
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int Id { get; set; }

        [Required]
        [StringLength(64)]
        public string Description { get; set; }

        public override bool Inactive { get; set; }

        [InverseProperty("Group")]
        public virtual ICollection<PersonEmployee> PersonEmployees { get; set; }
        [InverseProperty("Group")]
        public virtual ICollection<TimeCard> TimeCards { get; set; }
    }
}

Open in new window



Open in new window

0
Hi,

I have this rest api request that returns a boolean value. Initially this value is always set to false but will turn to true within seconds (or up to a minute) . I need to do re-do or poll the request until the status of the value has changed from false to true and then, of course, stop the request(s) and continue.

What kind of methods can I use to make this happen.

Grateful for help and example code.

Peter
0
I have a web application I have been developing on my development environment (VS2010).  When I load the application (one asp.net page and code behind) onto the server the rendering is different.  For some controls it is much different.  Charts are use are much smaller than the should be.  Borders on drop down lists are not rendered the same either.

Both my development server (local PC) and sql server use IE11, IIS7.  SQL Server 2012R2.

Any help would be greatly appreciated.

Thanks,
0
I have an asp.net web application with a grid.  One column has a bulleted list with displaytype as Hyperlink. It is databound. I return some folder paths in this list. If the path is a share on a server all works find as example 1.

In example 1 the spaces are replace by %20.

But for some reason in Example 2 when the actual drive letter is used the spaces are replaced by %2520 which then does not work.

1.file://server1/scanned/ASB/DE/AGOPSOWICZ,%20DANIEL/AGOPSOWICZ,%20DANIEL%202018%2011%2014


2.file:///Q:/ASB/DE/AGOPSOWICZ,%2520DANIEL/AGOPSOWICZ,%2520DANIEL%25202019%252002%252021


What causes this %2520 to happen? In example 1 with %20 the link works.

It looks like an encoding issue in the Bulleted list Hyperlink. It is adding the %2520 on the Example 2.

Thanks,

Roger
0
Hi,

I have these classes:

Public Class Party
    Public Property partyIdentifier As String
    Public Property email As String
    Public Property telephone As String
    Public Property role As String
End Class

Public Class Car
    Public Property registrationNumber As String
    Public Property registrationNumberMissing As Boolean
    Public Property model As String
    Public Property used As Boolean
    Public Property year As Integer
    Public Property mileage As Integer
    Public Property objectGroupType As String
End Class

Public Class Calculation
    Public Property cashPrice As Integer
    Public Property downPayment As Integer
    Public Property residualDebt As Integer
    Public Property creditTime As Integer
    Public Property interest As Double
End Class

Public Class Insurance
    Public Property monthlyCost As Integer
End Class

Public Class Finance
    Public Property contractType As String
    Public Property customerType As String
    Public Property customerLicenceType As String
    Public Property Parties As List(Of Party)
    Public Property car As Car
    Public Property calculation As Calculation
    Public Property profileId As Integer
    Public Property campaignId As Integer
    Public Property plannedDeliveryDate As DateTime
    Public Property insurance As Insurance
End Class

Open in new window


I'm now trying to build this as an object that I can serialize into json like this:
 If Not Page.IsPostBack Then
            Dim f As New Finance

            ' Basic
            f.contractType = "Installment"
            f.customerType = "Private"
            f.customerLicenceType = "SwedishDriversLicense"

            ' Parties
            Dim p As New Party With {
                .partyIdentifier = "8811119307",
                .email = "nordberg.peter@gmail.com",
                .telephone = "0854545656",
                .role = "Buyer"
            }
            f.Parties.Add(p)

            Dim json As String = JsonConvert.SerializeObject(f)
            Label1.Text = json
        End If

Open in new window


The problem is that I get an error that an object doesn't exist when adding an party item to the lost of parties as can be seen in below image.
 Objkect error
What am I doing wrong and how can I fix it?

Peter
0

ASP.NET

125K

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