How to display due date from created date by subtracting days in asp.net
I am trying to get the due date according to the date created in asp.net (VB). Below is the example.
Created Date: 20/11/2020
Subtract (-) : 30 days
Result: Due Date (00/00/0000)
See also questions close to this topic
-
Using Steeltoe DiscoveryHttpMessageHandler with FlurlClient
I am looking to switch our HttpClients to use Flurl. However, our HttpClient is currently configured to use Service Discovery via Steeltoe. Basically it's doing this in ConfigureServices:
services.AddHttpClient<IMyClass, MyClass>().AddHttpMessageHandler<DiscoveryHttpMessageHandler>();
DiscoveryHttpMessageHandler is a custom http message handler in the Steeltoe library (https://github.com/SteeltoeOSS)
How do I access the IHttpClientBuilder with Flurl so I can add this same message hander? Or is there another clean way with Flurl to add a custom message handler for every HttpClient/FlurlClient created?
-
Get time ticks in DateTime format C#
Date time comes from Database side like this
"2021-03-08T21:27:21.065"
and then i have tried and format it from C# side like below,string fullDate = Convert.ToDateTime(x.start_date).ToString("dd-MM-yyyy HH:mm:ss");
But i need to show last part of the date
065
as well. -
How to add custom logics (ie. Encoding) on pre-render WebControl event
I inherit an ASP.NET application with hundreds of WebForm pages with Label displays data from server. In order to protect from XSS attack I encoding its content prior to rendering:
Create a sub class calls EncodedLabel and update the asp:Label with asp:EncodedLabel tags and it seems to work well.
public class EncodedLabel : Label { public override void RenderControl(HtmlTextWriter writer) { //Let's encode first. this.Text = AntiXssEncoder.HtmlEncode(this.Text, true); //Continue with client rendering. base.RenderControl(writer); } }
I don't like this solution as much because all Labels have to be replaced.
Since Label inherits from WebControl and Control class, can I do something at the WebControl level to make this encoding automatic for all labels?
- Change the behavior on WebControl prerender event
- Perhaps create an Extension Method for WebControl class which performs the encode.
- If the control is label, encode it by calling the extension method before continue with render.
Is this even the right approach? I have difficulties putting this into codes and have Webcontrol prerender calling this extension method.
public static class EncodeLabelControls { public static void EncodeXSSClass(this WebControl control) { if(control is Label) { Label ctrl = (Label)control; ctrl.Text = AntiXssEncoder.HtmlEncode(ctrl.Text, true); } } }
-
Why would a .g.vb file for a WPF form not be generated in Visual Studio 2019?
I have a form in a WPF application that is generating an error message:
"BC30451: 'InitializeComponent()'is not declared. It may be inaccessible due to its protection level"
InitializeComponent()
is a function that is generated in the .G.VB file associated with a XAML file. If the .G.VB is not generated, there is noInitialzeComponent()
function.The steps that I have taken thus far are:
- Compare the properties of the XAML file that is not generating a .G.VB to the properties of a XAML file that is producing a .G.VB file.
- I tried a
Build | Clean Solution
; followed by aBuild | Rebuild Solution
. - Made sure that the namespace and class are the same in the VB and XAML x:Class.
- Closed and re-started Visual Studio 2019.
- Added a
InitializeComponent()
function to the class.
This will need to be documented so we know that this is typically automatically generated. Doing this leaves the code vulnerable to future changes made in the designer.
The properties for the XAML file are set as:
- Build Action:
Page
- Copy to Output Directory:
Do not copyist item
- Custom Tool:
XamlIntelliSenseFileGenerator
My questions are:
- What prevents the .G.VB file from being automatically generated?
- What is the best resource to diagnose the cause of this issue?
-
Is anyone familiar with adding user delegates in RightFax through the webapi?
I'm working on creating an application that can be used to easily lookup rightfax users/groups with a fax number, and then allow users to add additional users as delegates to the main user for the group, but I haven't been able to figure out exactly how to go about doing that.
The way the properties are structures in the API, theres the User object, and the delegates for that user are part of a delegates collection that can be found under User.AccessibleByTheseUsers. The delegates collection can only have delegate objects added to it (not users), although the delegate object has a .User property where you can specify the User object attached to the Delegate. The Delegates collection object has properties for add and create, and I've tried everyway I can think of to add a delegate to the delegate collection with the delegate.user object set to the user i want added. I think I'm close, but whenever I try to save the delegate collection with the new delegate object, it throws an error that the new delegate objects Handle property is null. If i try to set Delegate.Handle = User.Handle, it throws an error that Delegate.Handle is a read-only property, so i can't set it, but it also doesn't seem to be generated automatically or inherited from the attached User object.
Has anyone worked with the RightFax API before and figured out how to correctly add a delegate to a user, or to a delegates collection?
-
Process details in VB.Net
I am trying to obtain details of a running process. I have access to the process, I mean by that I can get the process object no problem.
Dim nmsdProc() As Process = Process.GetProcesses If nmsdProc.Length > 0 Then 'First we need to check is For Each p As Process In nmsdProc 'Check if nmsd is running If p.ProcessName = "nmsd" Then 'nmsd is running: check if there's an active CREO session For Each px As Process In nmsdProc If px.ProcessName = "xtop" Then 'Process xtop.exe is running meaning there's an active CREO session 'can't stop nmsd.exe in this case ... exiting sub function Exit Sub End If Next p.Kill() Exit For 'no need to continue looping through processes End If Next Else MsgBox("Problem with NMSD find function") End If
I would like to find details like ProcessExplorer is able to display. ProcessExplorer results It's this line "File" with a local path that I would like to be able to read. Any idea of how this can be done?