|
When we are using Microsoft Test runner we use Moq to build out our mock data layer. We recently have been switching to xUnit, I haven't tried using Moq with it yet.
Here is the link to the Moq GitHub repo, there's good info here.
|
|
|
|
|
Hi,
I am trying to learn React.Js, I am trying to start with a small Hello World application, the problem is, I am not able to integrate React.Js with with MVC that I have or even MVVM, what I want is, I write some jsx file I want to execute it part of my MVC application. Just like I used to write code for my previous applications and just execute them when I press F5, am I doing anything wrong here? Can't I write jsx files as part of my MVC application and call them and execute them just by pressing F5?
Any guide for me for integrating my MVC or Web Api application with React.Js or Angular 2.0 anything is fine, I am getting very frustrated because there very less help for executing React or Angular as part of Visual Studio, I am searching a lot, but I couldn't execute even a single link successfully.
Need some help, if anything that can explain me those basic things to execute at least one application successfully - please.
I put some money in Udemy for react that guy is teaching more of Passport than react and ASP.Net MVC full stack - very sad.
Any help a link or a suggestion anything helps me, because even the errors are not descriptive they are not explaining me why something is failing - frustrated, please any help.
|
|
|
|
|
Have you created your project type as a Web Application type? Other types won't fire up the internal IIS Express server. This is moot if you're rolling with a stand-alone web server, but that doesn't sound like the case.
If you're using MVC, is your base jsx being served by your home controller? If not, that would be a problem, but I frankly wouldn't use MVC.NET for this, I would use WebAPI with a static files section.
You might get some ideas for URL management at:
Serving URLs with File Extensions in an ASP.NET MVC Application - Rick Strahl's Web Log
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
I applaud your ambition on learning React or Angular, a path I took last year and started out integrating my learning with a MVC project which was quite a steep learning curve. Yes you can integrate ReactJs and Angular into a MVC project, and even a .Net Core project, but you have to change the way you think about programming and .Net.
Keep in mind that ReactJs and Angular doesn't require a .Net environment. .Net is just used as a back end to feed data to the client script pages. In hindsight, I found using .Net for the back end much harder to deal with than using say pure Java or Typescript for the whole thing.
I would like to seed your ambition with some files and code, but It's just too large to post here.
I actually build a large project that uses ReactJs both client and server side and works great.
But rendering ReactJs on the server side requires a library of JavaScriptEngines which gets complicated.
Start with the client side first, then work your way to the server side.
But this is where I started.
React integration for ASP.NET MVC | ReactJS.NET
Follow the tutorial
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I have 2 .net forms, each with their own BindingSource which I set to go after the same DataTable. The table is filled early on with 35 rows. One of the BindingSources has a filter set when the form loads, which makes the result set 4 rows. When I go back to the first form, the row count has gone down to 4 - if I set that BindingSource filter to "", the count returns to 35.
It looks as if the two binding sources are sharing stuff, where changing the filter on one affects the other.
Any explanation for this? I am working around it but would like to understand the mechanism.
Bob
|
|
|
|
|
Maybe I'm confused, but this post is in ASP.NET Web Development. Right?
In ASP.NET Web development, there is no BindingSource. (or am I crazy ?)
There is SQLdatasource (and other datasources).
Is this Post supposed to be in the Windows Development area?
If you need help with SQLdatasource, I can offer some assistance; just need a code example.
David
|
|
|
|
|
Thanks, you are correct, BindingSource is probably specific to win forms and not one of the many shared classes with asp.net. I will repost in the win dev area, this problem is specific to the BindingSource implementation.
|
|
|
|
|
<div class="container">
<iframe>
<html>
<body contenteditable="true">fddsfg fds dgdfgdsgfdsgds
</body
</html>
</iframe>
</div
https://stackoverflow.com/questions/1125292/how-to-move-cursor-to-end-of-contenteditable-entity
I tried above link in both ways like below.
setCaretToEnd('.richeditor .container');
//var s= $('.richeditor .container');
//setEndOfContenteditable(s);
but, Still, the cursor is nr working...Any help appreciated.
|
|
|
|
|
My code looks like below.How to focus cursor at the end of iframe body when page loads.
#documnt
<html>
<hrad></head>
<body> aaaaaaaaaa bbbbbbbbbb ccccccccc dddd eeeeeeeeeee</body>
</html>
Thanks for your answer.
|
|
|
|
|
What do you mean by "cursor"? If you mean the mouse pointer then you can't control that, if you mean the caret then html doesn't support that, only text boxes do.
|
|
|
|
|
Good Afternoon,
I am working on a project where I will need a custom control added to a site. Since I have never worked with them previously, I decided to try and make a very basic control and a test site so I can learn how to do everything properly. For instructions, I was using the steps outlined on Microsoft's website here. Therefore I created a solution with two projects - Custom Control Assembly and Custom Control Test Site, both of which are using the 4.7 version of the .NET Framework.
For the Custom Control Assembly, the Assembly name is CustomControlAssembly and the Default namespace is CustomControlNamepsace. There is one file in the project called CustomControl which inherits from
System.Web.UI.Control . This project built without any errors and I copied the CustomControlAssembly.dll to the /Custom Control Test/Custom Control Test Site/bin folder as instructed on the Microsoft page listed above.
The Custom Control Test Site is a web forms site. On the Default.aspx page I added the following directive right underneath the
<%@ Page %> directive:
<%@ Register TagPrefix="Custom" Namespace="CustomControlNamespace" Assembly="CustomControlAssembly" %>
In the page, I am able to add the following tag and IntelliSense correctly finds it:
<Custom:CustomControl runat="server"></Custom:CustomControl>
However, if I try to add an ID properties (in order to name it like I do with all ASP.NET controls), like the following:
<Custom:CustomControl runat="server" ID="CustomControl1"></Custom:CustomControl>
I get the following error message:
CS0400 - The type or namespace name 'CustomControlNamespace' could not be found in the global namespace (are you missing an assembly reference?)
If I take the ID="CustomControl1" out of the tag, then the site will build fine again. However, when I run the site, the custom control does not show anything on the site. I tried updating the CustomControl to inherit from
System.Web.UI.UserControl instead of
System.Web.UI.Control but it still doesn't display on the Default.aspx page. The following is the markup of the CustomControl.ascx file:
<pre><%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomControl.ascx.cs" Inherits="CustomControlNamespace.CustomControl" %>
<table>
<tr>
<td>First Name:</td>
<td><asp:TextBox runat="server" ID="txtFirstName"></asp:TextBox></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox runat="server" ID="txtLastName"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><asp:Button runat="server" ID="btnShowName" Text="Show Name" OnClick="btnShowName_Click"/></td>
</tr>
</table>
<br/>
<br/>
<asp:Label runat="server" ID="lblFullName"></asp:Label>
And the code-behind is:
using System;
namespace CustomControlNamespace
{
public partial class CustomControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnShowName_Click(object sender, EventArgs e)
{
string firstName = txtFirstName.Text.Trim();
string lastName = txtLastName.Text.Trim();
string fullName = $"Hello {firstName} {lastName}! If you are seeing this message, then the custom control " +
$"is working successfully.";
lblFullName.Text = fullName;
}
}
}
So I have two errors - First, why can't I added an ID to the custom control and second, and more importantly, why is the custom control not showing on the Default.aspx page even though the control and site built fine, without any errors or warning. Even when I inspect the HTML of the Default.aspx page, where the control should be, it is just empty.
Any help, guidance, or suggestions would be greatly appreciated. I have been at this for over an hour and a half and can't find anything that would explain why these issues are occurring. Thanks in advance for any help you can provide.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Imagine the following scenario:
1) the user clicks on a button 2) the application does download file in the OnExecute action 3) after some time, the download is done and the user shall see a confirmation-message, that everything was going right.
The process should be asynchronous and should be visualized in some way (for example, with a progress bar), in other words the end-user may work with other parts of the application (Like working with other tabs in web application)during a heavy download process, watch the process status and he will be notified about the process completion.
Any Suggestions on how to implement this scenario?
$('#btnExport').on('click', function (e)
{ window.location.href = "/Export/GetExport; }
public void GetExport(){ //Downloads Data }
The file gets downloaded but the user has to wait until the files gets downloaded. I want free the UI so that user can perform other operations during the download.
|
|
|
|
|
That's not possible as browsers control file downloads for security reasons. For your page to react to the download it would need a hook into the download process which it simply doesn't have.
|
|
|
|
|
If you can drop support for old browsers - including any version of Internet Explorer - then something like this might work:
Javascript - Downloading Files with AJAX and Showing a Progess Bar[^]
NB: If the user navigates away from your page whilst the file is downloading, the download will be aborted. It's generally much safer to use the standard file download options, which will let the browser continue downloading the file in the background whilst the user continues working.
You'll also want to make sure that you add the SessionStateAttribute[^] to your Export controller to disable session state, or set it to read-only. Without that attribute, only one request for a single session can be processed at a time.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I did try by applying [SessionState(SessionStateBehavior.ReadOnly)] to the Export Controller but when I click on download and navigate to another pages(download process is being prepared like getting data from database and loads into excel and then downloads) download stops.
How to achieve this?: the standard file download options, which will let the browser continue downloading the file in the background whilst the user continues working.
|
|
|
|
|
you can use hangfire to do that
=====================================================
The grass is always greener on the other side of the fence
|
|
|
|
|
In my ASP.Net (C#) webforms application, I've noticed that some (all?) of the generated form fields have an extra attribute, "wtx-context" with a GUID value; e.g.
<input type="submit" name="ctl00$grdConfig$ctl04$btnAdd" value="Add New" id="btnAdd" wtx-context="FC3AB902-A74E-4209-8E0D-9F9AC5F15021"> I don't recall ever seeing this in any other of my sites, yet it's happening when running the site via VS2015's development server, and when running on a remote shared host. Searching Google for "wtx-context" returns virtually nothing, and nothing relevant.
Has anyone else come across this, what does it do, and is it an issue?
Confused!
|
|
|
|
|
Hi,
I'm seeing this too - did you ever figure it out?
Ben
|
|
|
|
|
No, never got to the bottom of it. I still see it occasionally, but not as much... Still no useful info when googling, though at least one other dev has seen it some time ago.
|
|
|
|
|
I am trying to insert HTML elements dynamically into an empty DIV element on my VB.net web form when buttons are clicked. Each button will insert a different set of elements. In my jQuery function I made sure the DIV that will receive the new contents is cleared before adding new contents to it.
This works if I take the script and markups and put them in a regular html file but when I try this in my VB.net web form, the new elements show up for a split second then they are cleared.
I think it has to do with PostBack so I put the code below in Pageload.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
ClientScript.RegisterHiddenField("isPostBack", "1")
End If
End Sub
Then in my jQuery document ready function I check for PostBack with the following code
var isPostBackObject = document.getElementById('isPostBack');
if (isPostBackObject != null) {
}
What am I doing wrong, why isn't it working?
modified 2-Dec-18 11:21am.
|
|
|
|
|
Chances are your code is instigating a postback which is causing the page to refresh. In the javascript you run when the button is clicked make sure the function returns false, or if you're using jquery then use e.preventDefault().
You can probably google "javasctipt prevent postback" for specific code examples.
|
|
|
|
|
Hey can someone kindly help me create models views and controllers using C sharp to write the code
|
|
|
|
|
Did you want to describe the problem your having with more detail?
As it stands now, there's really nothing for anyone to say other than to tell you to either find MVC tutorials on the web or pick up a book on MVC.
|
|
|
|
|
I need help adding html helpers,partial pages,JavaScript ,DbInitializer
|
|
|
|
|
As Dave already suggested, you need to Google for articles or get hold of a good book. No one here is going to do the work for you.
|
|
|
|