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

Please help me understand why C# throws this error when there's already a return statement there? I can add another return to fix it but why does it do that?

ee1.png
This is how I can fix it

public decimal CashBonusBalance
		{
			set {this.label_CashBonusBalance.Text = string.Format("{0:C}",value);}
            get
            {
                if (label_CashBonusBalance != null)
                    return decimal.Parse(label_CashBonusBalance.Text);
                return 0; //**** adding an extra return
            }
        }

Open in new window

0
Hi

In ASP.net I have a panel that I want to show a label in on the far left and then an image on the far right.
What is the best way to do this so that no matter what size the screen the label floats to the left and the image to the right
0
I have the following html code

@foreach (var e in ViewBag.Enterprise)
    {

    <li class="configurator-enterprise-li" id="@e.Id">
        <span>@e.Name</span>

        <ul id="site-ul">
            @foreach (var s in ViewBag.Sites)
            {

                <li class="site-li" id="@s.SiteId">@s.SiteName</li>
			}
    ...

Open in new window


This works well with 1 enterprise

But when I add 2 enterprises to the results, it list like this

Ent1
  - site1
  - site2
  - site3
Ent2
  - site1
  - site2
  - site3

instead of
Ent1
  - site2
  - site3
Ent2
  - site1


How do adjust the code so it only shows the correct data

Inside SITE there is a EnterpriseId
i.e. s.EnterpriseId

So I would need a where clause or something similar in razor?
0
Hi, I have requirement to use Kerberos authentication for ASP.NET WebAPI application deployed in Docker Swarm .NET Core linux containers. WebApi will be used by web clients with Kerberos support. Application also should be connected to active directory to subscribe and get list of all users from AD. Docker Swarm deployed on premises in the organization network. Anyone have experience with such configuration?
- What should be done to enable Kerberos authentication in the ASP.NET and its Docker linux image? Will this require 3rd party kerberos tools or it can be handled by .NET Core?
- To enable such configuration what should be configured in the SWARM cluster?
- What should be used as service principal names (SPN)? And how to get user AD Identity inside ASP.NET?
- Is it possible to use multiple container instances of the same application?
- How I could use background worker service inside SWARM cluster to sync users list with the AD database?
0
Hi
In Visual Studio 2017 I want to create a web app that will run on a dot net 4 platform. If I create a new web app it defaults to 4.6.1. How do I create a web app for dot net 4?
0
From my website. I need to allow user to be able to delete files from a shared folders.  How do I impersonate a non-windows account? I need to connect to a multiple Linux shared folder. so I do not want to map a drive letter. I currently use the below command, but I do not want to show my user name and password. I'm able to get the command below to work with impersonate with my windows account but .net impersonate does not work on non-windows accounts.  I need a solution that will let me connect to a shared folder using a non-windows account.

Example: I'm using the .Net ProcessStartInfo.Arguments Property

startInfo.FileName = "net";
startInfo.Arguments = "use \\\\Servername\serverPath serverPassword /user:serverUsername";
Process.Start(startInfo);
0
JavaScript - Pass JS Variable Value to Hidden ASP.net Form Field so VB.net code can use that value on post back

I have this code i am working with right now below in Code Block...

This code creating a count integer variable (howManyUnhidden) that i want to pass to the hidden ASP.net field...

Code Solution One: https://www.codeproject.com/Questions/708697/Pass-javascript-variables-value-to-Csharp-code-beh

Code Solution Two: https://stackoverflow.com/questions/14977491/pass-javascript-variable-to-c-sharp-code-behind

Which is better ?? --- Best way to go... Most robust ??

Or maybe a BETTER code example to show me that is a better way to go... ?

$(function () {
           var howManyUnhidden = $("#HiddenField1").val() || 0;
          $('.childblock:lt(' + howManyUnhidden + ')').show();

          $('#addChildBlock').click(function (e) {
             e.preventDefault();
             var block = $('.childblock:hidden:first');
             if (block.length) block.show();
             if (howManyUnhidden <= 4) {
                 howManyUnhidden++;
                 $("#HiddenField1").val(howManyUnhidden);
                 //alert(howManyUnhidden);
             }
          });

          $('.closeChildBlock').click(function (e) {
             e.preventDefault();
             $('.childblock:visible:last').hide();
             if (howManyUnhidden > 0) {
                 howManyUnhidden--;
                 $("#HiddenField1").val(howManyUnhidden);
        

Open in new window

0
Cannot establish AdomdConnection in my ASP MVC C# application via the msmdpump.dll at all to connect to my cube

However if i use the same connection strings credentials to log into the Cube via Excel I have no problem.

Its gives me an "Object not set to an instant of an object"

lsConnectionString = "Provider=msolap; Persist Security Info=True; Data Source=\"https://reporting.q88.com\"; Initial Catalog=" + InitialCatalog + "; Cube=" + CubeName + "; User ID=HI\\vmDemo; Password=vmPassword1";


using (AdomdConnection connection = new AdomdConnection(lsConnectionString))
{
         connection.Open();
 }

Open in new window

I tried various logins but still the same result. Any ideas?


and here is a stacktrace
   
at Microsoft.AnalysisServices.AdomdClient.HttpStream.ImpersonateLogonIdentityAndExecute(Action action)
   at Microsoft.AnalysisServices.AdomdClient.HttpStream.GetRequestStream()
   at Microsoft.AnalysisServices.AdomdClient.HttpStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at Microsoft.AnalysisServices.AdomdClient.CompressedStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Flush()
   at System.Xml.XmlTextWriter.Flush()
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.EndRequest(Boolean useBinaryXml)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean 

Open in new window

0
I need to get Certificate Info from a PDF Form.  Not sure how to do this with iTextSharp.

Here is some sample code:

[HttpPost]
        public ActionResult Upload(HttpPostedFileBase file, string Name)
        {

            if (file != null && file.ContentLength > 0)
            {
                    string pdfTemplate = "NewRequest.pdf";
                    byte[] pdfbytes = null;

                    BinaryReader rdr = new BinaryReader(file.InputStream);
                    pdfbytes = rdr.ReadBytes((int)file.ContentLength);
                    PdfReader reader = new PdfReader(pdfbytes);
                    //PdfReader _reader = new PdfReader((byte[])file).ToArray();

                    string t = Name.Trim().Length == 0 ? null : Name;
                    var fields = reader.AcroFields.Fields;
                    var RequestID = reader.AcroFields.GetField("requestId");
                    CultureInfo MyCultureInfo = new CultureInfo("en-US");
                    var OpenDate = reader.AcroFields.GetField("openDate");
                    DateTime? OpenDate2 = null;
                    try
                    {
                        OpenDate2 = DateTime.ParseExact(OpenDate, "d/M/yyyy h:mm", MyCultureInfo);
                    }
                    catch
                    {
                        OpenDate2 = null;
                    }
                    var Org = reader.AcroFields.GetField("organization");
                    DateTime? NeedDate = 

Open in new window

0
ASP.net Web Form - PostBack Event Issue Problem...

The VB.net PostBack is re-hiding specific Div Blocks that were in a state of show or display -- (from user JScript click events) before the Postback


One set of 3 Div Blocks is hidden by CSS CLASS adultblock default setting of display:none when page loads
       
        .adultblock {
            display: none;
        }

Each of the 3 Div blocks of the class adultblock has unique id element too but not used right now in JScript

        #HideA2, #HideA3, #HideA4 {
        }

Another set of 5 Div Blocks is hidden by CSS CLASS childblock default setting of display:none when page loads

        .childblock {
            display: none;
        }

Each of the 5 Div blocks of the class childblock has unique id element too but not used right now in JScript

        #HideC2, #HideC3, #HideC4, #HideC5, #HideC6 {
        }

Here is the code from the Java Script that SHOWS each of the DIVs in sequence for the adultblock with an Add Adult button and removes each via a Remove Adult Button
 
        $(function () {
             $('#addAdultBlock').click(function (e) {
                 e.preventDefault();
                 var block = $('.adultblock:hidden:first');
                 if (block.length) block.show();
             });

             $('.closeAdultBlock').click(function (e) {
                 e.preventDefault();
                 $('.adultblock:visible:last').hide();
             });
        });

Open in new window

Code same for Add Remove child div blocks...

Open in new window

0
I've inherited an ASP.NET MVC, dot Net Framework 4.5.
It was built with angular js and it has a CSharp API file, SurveyAPIController.cs .
As I step through the debugger, there is a place it seems like it should be calling the GetResultSummary function in SurveyAPIController.cs here in a service.js file :

    .factory('SummaryService', function ($http) {
        return {
            getSummary: function (term, classid, faculty, callback) {
                $http.get('../api/surveyapi/getresultsummary?Term=' + term + '&Class=' + classid + '&Faculty=' + faculty).success(callback);
            }
        };
    })

Open in new window


I put breakpoints in the GetResultSummary function, but they never get hit.

The GetResultSummary function calls a SQL Server stored procedure:
            var Result = db.Database.SqlQuery<vmResult>("Exec [sur].[GetResultSummary]  @TermID={0},@ClassID={1},@FacultyID={2}", Term, Class, Faculty).ToList();

Open in new window


When I run the SQL Server Profiler when I expect that stored procedure to be hit, I don't see it run. Maybe the stored proc is getting hit and I'm not seeing it, but I don't see it

After the debugger gets done with service.js function,
 .factory('SummaryService', function ($http) {

Open in new window

the debugger then goes to an app.js file where it tries to read some data:
        SummaryService.getSummary($scope.term, $scope.classid, $scope.faculty, function (data) {
            if (data != null) {
                $scope.summary = data;

Open in new window


But it appears that the data variable is null.
The only thing I see going wrong is that before the  
.factory('SummaryService', function ($http) { 

Open in new window

code gets called, there is an error in a nv.d3.min.js[dynamic] file :
Unhandled exception at line 1, column 408 in https://rawgit.com/novus/nvd3/v1.1.15-beta/nv.d3.min.js
0x800a1391 - JavaScript runtime error: 'd3' is undefined occurred

But I don't know if that is related since the JavaScript functions gets all its parameters filled successfully with real arguments.
Why is the API function not getting called?
By the way, there are other functions in that API file that do get called with the same path.
0
Hi

In my ASP.net web app I use the following code to create a link that will appear in emails. I want the link to look more like a button, possibly with
a gradient affect. How would I do this? Thanks

            oLink = "http://xxxxx.azurewebsites.net/progressive_report?oLoadShaft=" & Replace(oShaft, " ", "%20")
            oHBody = oHBody & "<br>"
            oHBody = oHBody & "<a href=" & oLink & ">" & oShaftandRegion & "</a>"
            oHBody = oHBody & "<br>"

Open in new window

0
I have a Asp.net MVC app which sends a float array data to the client

float[320,240]
See attached for the data, its around 1.4mb

I need to dramatically reduce this size, and be able to convert it to the current format in Javascript

Here is the request
 $.ajax({
  type: "POST",
  url: "@Url.Action("CameraChange", "Home")",
  async:true,
  data: "{'cameraId':'" + ID + "'}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function (response) {
                 imageTemperatureDataArray = JSON.parse(response.TemperatureDataArray);
  },
   error: function (e) {
       alert("error: " + e.message + ' ');
  }
 });

Open in new window


Then I use it futher down in
 
  $("img#schemesImageSchemes").mousemove(function (e) {
       $('#dataSchemes').text(imageTemperatureDataArray[myX][myY]);
});

Open in new window


Is there a way to reduce this size of the attached
And how would i then convert it in JS ?
floattemparray.txt
0
Hi

In my ASP.net chart I used the following VB.net code in the pie chart series
The problem is that it substantially shrunk the size of the actual chart
Is there a way to stop the actual chart from shrinking so much?
I have included an image of the chart with the code and below that without it.
Please ignore the different percentages. I used two different data sets but the shrinkage was the same

       series1.Label = "#VALX (#PERCENT)"
            series1("PieLabelStyle") = "Outside"
            series1("PieStartAngle") = "45"

Open in new window


1
2
0
Hi

I am adding the following chart using the code below (ASP.net VB.net). The problem is that the data is too bunched up.
How can I make it more readable? One way would be to have lines linking to a percentage and word outside the chart.
Another way would be to expand the size of the legend and have all the data there. I am not sure how to do either.

Recommendations and code changes around these would be greatly appreciated. Thanks

1
    Sub oChart4(ByVal oChartWidth As Integer, ByVal oChartHeight As Integer, oSQL As String,
          ByVal X_Axis_Column As String, ByVal Y_Axis_Column As String, ByVal oAdd_To_Panel As Panel)
        ' Initialize the Chart object    
        Dim ChartData As New Chart()
          ChartData.BorderSkin.SkinStyle = BorderSkinStyle.Raised

        Dim legend1 As New Legend()

        ' Set the Legend properties
        legend1.Name = "Default"
        legend1.Docking = Docking.Bottom
        legend1.LegendStyle = LegendStyle.Row
        legend1.Alignment = System.Drawing.StringAlignment.Center

        legend1.BackColor = System.Drawing.Color.Transparent
        legend1.BorderColor = System.Drawing.Color.Black
        legend1.BorderWidth = 1
        ' Add the Legend to the Chart
        ChartData.Legends.Add(legend1)


        ' Initialize objects and elements
        Dim chartArea1 As New ChartArea()
        chartArea1.AxisX.Interval = 1


        ChartData.BackColor = System.Drawing.Color.White
        

Open in new window

0
Hi

In my ASP.net web app I have two charts and GridViews that are loaded on page load.

Both the Gridviews are not visible. I have a checkbox above each GridView. If the user
checks the box then I want the GridView to become visible.

Is there a way to do this without having to reload the charts which at the moment disappear
on postback
0
I am working on a vb asp.net project that needs to export an excel work sheet into a sql server 2014 table

Not sure the best way to do this

Any advice????
0
I’m creating a asp.net core application.

Anyone know a good shared hosting ?

Anyone use godaddy windows shared hosting plan to deploy a asp.net core website?
0
Is there a way to force a Control+F5 on a user? We publish our code and the style sheets look horrible until they do a control+F5, but other than putting a message on the screen, how do we trigger the style sheets to update?

thanks!
0
I have a datagrid with rows of employees.

I want to click an item in the grid row that will open a popup filled with further details about the selected employee. Not a tooltip.

Any recommendations on how one might do this?

UpdatePanel?
WebMethod?

Can you direct me to a page where something similar has been done?

I know how to show and hide a panel which looks like a popup, so I don't need direction on that.

Thanks!
0
I recently upgraded from jQuery 1.11.1 to jQuery 3.0.0 and now  a simple change on a couple of radio buttons no longer works. How can I get this back to working as it should?

    <script type="text/javascript">
       jQuery(document).ready(function () {
            j$('#cmdCreateNewEvent').prop('disabled', 'disabled');

            $('#rdoSameDonor').change(function () {
                EnableCreateButton();
            });
            $('#rdoDifferentDonor').change(function () {
                EnableCreateButton();
            });
        });

        function EnableCreateButton() {
            $('#cmdCreateNewEvent').removeProp('disabled');
        }
    </script>

Open in new window

0
We need to convert part of our MS Access DB to a web app.  ASPX or .net.  No experience in web apps.  Ideas?
0
Hi

I am using the following VB.net code in creating an ASP.net chart
        Dim series4 As New Series()
        series4.Name = "Series 4"
        series4.ChartType = SeriesChartType.Line
        series4.Color = Drawing.Color.Green
        series4.BorderWidth = 2
        series4.XValueMember = "Date"
        series4.YValueMembers = "Day Work Rate"
        series4.LegendText = "Day Work Rate"
  ChartData.Series.Add(series4)

Open in new window


I want to flip the axes of the chart. Should I just use

 series4.XValueMember = " series4.XValueMember = "Date"
        series4.YValueMembers = "Day Work Rate"
        series4.YValueMembers = "Date"
        series4.LegendText = "Date"

Open in new window

0
I have an asp.net/c# Web Forms project I am developing and am stuck on one part. I have a Grid that on the ItemDataBound event, is applying various CSS styles to color the grid rows based on shipping status. Based on a particular status, I also need to show / hide various checkboxes in the EditForm (autogenerated). I am having a difficult time getting the variable types GridDataItem and GridEditFormItem to work together in the same method. I have included a screenshot of what Im trying to accomplish as well as my aspx and cs codes below.
Thanks in advance for anyone's help.

ASPX:
<telerik:RadGrid ID="RadGrid2" runat="server" AutoGenerateColumns="False" 
          AutoGenerateEditColumn="False"  Skin="Web20" DataSourceID="SqlDataSource2" OnItemDataBound="RadGrid2_ItemDataBound" GridLines="Horizontal"> 
        <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
          <ClientSettings>
              <Scrolling AllowScroll="True" UseStaticHeaders="True" />
          </ClientSettings>
          <MasterTableView AllowAutomaticDeletes="True" AllowAutomaticUpdates="True"  DataKeyNames="TransID">              
               <Columns>
                //Databound Columns  
              </Columns>
              <EditFormSettings EditFormType="Template">
                  <EditColumn UniqueName="EditCommandColumn1"  FilterControlAltText="Filter EditCommandColumn1 column" EditText="Details"></EditColumn>
                  <FormTemplate>
        

Open in new window

0
I want to post a MP3 file on my asp.net website.  I am using vb.net.   When the user clicks on the file I need it to play.  One option I tried was to just put a hyperlink to the file.  On edge and chrome it works fine but in IE it asks to download or run.   I need the file to play without asking to download or run.    Any help would be appreciated.

thank you
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