Alternative for ShowDialog in ASP .net
Am coming from C#.net, VB.net back ground to ASP.net. I used them for long time; but the current project is in ASP.Net.
I want alternative for ShowDialog. One important feature of showdialog (which I want) was the code following it is not executed until after the dialog box is closed.
Some jquery alternatives for showdialog I have found but they don’t stop execution of code following it (until form or dialog is closed).
Any suggestions
See also questions close to this topic
-
How to create an order from a cart in Mongoose and delete cart
I am trying to: a) Create an order from my current cart b) Populate the response of the order with the selected object attributes in the "select" c) Finally, I would like to delete the cart.
I have tried the below but here are my problems:
- the result response does not come back populated even if the
prevProductsQuantity
constant is indeed populated - I created the function cartClear to receive the cart id and delete the document from the model but it is not working.
- I am able to create many "same" orders so I think i need to manage with a conditiona but not sure where.
The response I am looking for:
{ "success": true, "data": { "_id": "607ed5c425ae063f7469a807", "userId": "6071aed0ed7ec9344cf9616c", "productsQuantity": [ { "_id": "607f2507994d5e4bf4d91879", "productId": { "productRef": "463b8bb7-6cf6-4a97-a665-ab5730b69ba2", "productName": "table", "brand": "boehm llc", "price": 713, "__v": 0, "createdAt": "2021-04-09T18:31:43.430Z", "updatedAt": "2021-04-09T18:31:43.430Z" }, "quantity": 2, "updatedAt": "2021-04-21T15:12:51.894Z", "createdAt": "2021-04-21T15:12:51.894Z" } ], "__v": 0 }
++ THE DELETION OF THE CART ++
The current response I am getting:
{ "success": true, "data": { "state": "pending-payment", "_id": "6080507a0c758608d0dc585c", "userId": "6071aed0ed7ec9344cf9616c", "totalPrice": 1426, "productsQuantity": [ { "_id": "607f2507994d5e4bf4d91879", "productId": "60709d8f24a9615d9cff2b69", "quantity": 2, "updatedAt": "2021-04-21T15:12:51.894Z", "createdAt": "2021-04-21T15:12:51.894Z" } ], "createdAt": "2021-04-21T16:19:06.056Z", "updatedAt": "2021-04-21T16:19:06.056Z", "__v": 0 }
** AND THE CART IS NOT DELETING **
this is the code I typed for these purposes.
Any guidance is super appreciated
router.post('/', [isAuthenticated], async (req, res, next) => { try { const cart = await CartModel.findOne({ userId: req.user }).populate({ path: 'productsQuantity.productId', select: { price: 1, brand: 1, productName: 1, productRef: 1, pictures: 1 } }); const prevProductsQuantity = cart .get('productsQuantity') .map((el) => el.toObject()); const totalPriceByProduct = prevProductsQuantity.map( (product) => product.productId.price * product.quantity ); const totalPrice = totalPriceByProduct.reduce(function (a, b) { return a + b; }); const result = await OrderModel.create({ userId: req.user, totalPrice: totalPrice, state: 'pending-payment', productsQuantity: prevProductsQuantity }); const cartClear = (id) => CartModel.deleteOne({ _id: id._id }); res.status(200).json({ success: true, data: result }); cartClear(`${cart._id.toString()}`); } catch (error) { next(error); } });
- the result response does not come back populated even if the
-
How to fetch SQL data using api and use that data in react-native-svg charts? I am having an API that I want to use to fetch data and display
I am fetching some data using an api. Inside that api there are SQL queries that are executed. I have api that will be used to fetch data or execute these queries. I want to know how can I replace my chart's static data with dynamic data that will be fetched from api.
Here is my
TabDashboardDetail.js
where I am fetching title for all charts based on api data:import React from 'react'; import DefaultScrollView from '../components/default/DefaultScrollView'; import ChartView from '../components/default/ChartView'; import CogniAreaChart from '../components/CogniAreaChart'; import { areaChartData } from '../chartData'; const TabDashboardDetail = ({ navigation, route }) => { const tabsConfig = route.params.tabsConfig; return ( <DefaultScrollView> {tabsConfig.components.map((comp, index) => { return ( <ChartView key={index} title={comp.name}> <CogniAreaChart areaChartData={areaChartData} height={200} /> </ChartView> ); })} </DefaultScrollView> ); }; export default TabDashboardDetail;
Here is my
CogniAreaChart.js
which is chart file that is currently being rendered:/* eslint-disable react-native/no-inline-styles */ import React from 'react'; import { View } from 'react-native'; import { AreaChart, YAxis, XAxis } from 'react-native-svg-charts'; import * as shape from 'd3-shape'; const CogniAreaChart = ({ areaChartData, visibility, ...props }) => { const xAxis = areaChartData.message.map((item) => item[Object.keys(item)[0]]); const areaChartY1 = areaChartData.message.map( (item) => item[Object.keys(item)[1]], ); return ( <View style={{ height: props.height, flexDirection: 'row', }}> <YAxis data={areaChartY1} contentInset={{ marginBottom: 20 }} svg={{ fill: 'grey', fontSize: 12, }} /> <View style={{ flex: 1 }}> <AreaChart style={{ flex: 1 }} data={areaChartY1} contentInset={{ top: 20, bottom: 20 }} curve={shape.curveNatural} svg={{ fill: 'rgba(134, 65, 244, 0.8)' }} /> <XAxis style={{ height: 20 }} data={areaChartY1} formatLabel={(value, index) => xAxis[index]} contentInset={{ left: 30, right: 30 }} svg={{ fill: 'grey', fontSize: 12, rotation: 35, originY: 5, y: 15, }} /> </View> </View> ); }; export default CogniAreaChart;
Here is areachartData that is currently being used in
CogniAreaChart.js
:export const areaChartData = { message: [ { year: '2018', quantity: 241.01956823922, sales: 74834.12976954, }, { year: '2019', quantity: 288.57247706422, sales: 80022.3050176429, }, ], status: 'success', };
I have the API that I will replace with the example if anyone suggests.
-
Sort,Filter,search in Javascript array
Given values for acctData and balances below, write a function that returns only an array of account numbers, and accepts the following optional parameters:
- user - sortBy (accepts "acctNum" or "balance") - sortDirection (accepts "asc" or "desc"; default to asc)
Execute your function and output the results as an array in console log for the following scenarios:
a) filtered by Bob b) filtered by Charlie c) sorted by acctNum d) filtered by Alice; sorted by balance ascending
acctData = [ { "acctNum": "AAA - 1234", "user": "Alice" }, { "acctNum": "AAA - 5231", "user": "Bob" }, { "acctNum": "AAA - 9921", "user": "Alice" }, { "acctNum": "AAA - 8191", "user": "Alice" } ]; balance = { "AAA - 1234": 4593.22, "AAA - 9921": 0, "AAA - 5231": 232142.5, "AAA - 8191": 4344 };
-
Formatting name
My input field allows only characters, no digits. I want when I type that the first character is in caps and small follows and anywhere is space do same, caps and small follows, and only one space should be allowed in the input field.
$(function() { $('#txttName').keydown(function(e) { if (e.shiftKey || e.ctrlKey || e.altKey) { e.preventDefault(); } else { var key = e.keyCode; if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) { e.preventDefault(); } } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <p>Name</p> <input id="txttName" value="">
-
How to popup modal when i choose a date
I am trying to popup a modal when i click on a specific date. My code is this. When i choose a date nothing happens and i dont know why
<input type="date" id="startdate1"name="startdate1"required> <div class="modal fade" id="fileUploadModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Add Comment</h4> </div> <div class="modal-body"> <p><textarea id = "commentsUpload"class="form-control custom-control" rows="3" style="resize:none"></textarea></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" onclick="submitXYX()" data-dismiss="modal">Submit</button> </div> </div> </div> </div> <script > $( document ).ready(function() { $( "#startdate1" ).change(function() { $('#fileUploadModal').modal('show') }); }); </script>
-
setTimeout inside setInterval does not work well
My code should change the class of the item in every second and repeat it forever.
function myFunction() { setInterval(function() { $("#item").addClass("class-one").removeClass("class-two"); setTimeout(function(){ $("#item").addClass("class-two").removeClass("class-one"); }, 1000); },1000); } myFunction();
First time the code works well, but after the loop starts again, it starts switching very fast. Can anybody tell me why?
-
Cascading databound <ajaxtoolkit:combobox> and <asp:dropdownlist> in asp.net
I have an
asp.net
search form that includes anajaxToolkit Combobox
and a standardasp DropDownList
. Both controls are bound to two separatedSqlDatasource
components.Something like this:
<ajaxToolkit:ComboBox ID="cbConvenzionato" runat="server" AutoCompleteMode="SuggestAppend" DropDownStyle="DropDownList" DataSourceID="sdsConvenzionati" DataTextField="nome" DataValueField="id" AutoPostBack="true" OnSelectedIndexChanged="cbConvenzionato_SelectedIndexChanged" /> <asp:DropDownList ID="ddlVeicoli" DataSourceID="sdsVeicoli" DataTextField="targa" DataValueField="id" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlVeicoli_SelectedIndexChanged" AppendDataBoundItems="true"> <asp:ListItem Text="TUTTI" Value="" Selected="True" /> </asp:DropDownList> <asp:SqlDataSource ID="sdsConvenzionati" runat="server" ConnectionString="<%$ ConnectionStrings:db %>" ProviderName="<%$ ConnectionStrings:db.ProviderName %>" SelectCommand=" SELECT id, nome FROM anag_convenzionati ORDER BY nome;" /> <asp:SqlDataSource ID="sdsVeicoli" runat="server" EnableCaching="false" CancelSelectOnNullParameter="false" ConnectionString="<%$ ConnectionStrings:db %>" ProviderName="<%$ ConnectionStrings:db.ProviderName %>" SelectCommand=" SELECT id, targa FROM veicoli_contratti WHERE ((@id_convenzionato IS NULL) OR (id_convenzionato = @id_convenzionato)) ORDER BY targa;"> <SelectParameters> <asp:ControlParameter Name="id_convenzionato" ControlID="cbConvenzionato" PropertyName="SelectedValue" Direction="Input" ConvertEmptyStringToNull="true" DbType="Int32" DefaultValue="" /> </SelectParameters> </asp:SqlDataSource>
There's also a third
sqldatasource
(sdsNoleggi
) that feeds agridview
but this's not a problem right now.In code behind I have two event handlers:
protected void cbConvenzionato_SelectedIndexChanged(object sender, EventArgs e) { sdsVeicoli.Select(DataSourceSelectArguments.Empty); Search(); } protected void ddlVeicoli_SelectedIndexChanged(object sender, EventArgs e) { Search(); } private void Search() { sdsNoleggi.Select(DataSourceSelectArguments.Empty); }
I tought in this way I should filter
ddlVeicoli
items after selecting an item incbConvenzionato
... but it's not working... why?If I look into
sdsVeicoli
SelectParameters
in debug I can seeid_convenzionato
being correctly set to selected value (id coming fromcbConvenzionato
) I bet also thatsdsNoleggi
dataset wiil be correctly updated with new values since I did this many times before. So why bound control it's not? I tried also to force addlVeicoli.DataBind()
aftersdsVeicoli.Select()
call ... but this had no effect. -
Swagger UI not working for REST API (asp.net web api2) application
I have asp.net mvc project with .NET Framework 4.7.2 and the same project contains asp.net web api2 controller in a separate folder : Controllers. The solution is legacy. The API are already in use in the PRODUCTION environment. Now I added the Swagger nuget package (Install-Package Swashbuckle -Version 5.6.0) to this existing project. Post that I see a SwaggerConfig.cs added to the App_Start folder of the Solution Explorer.
Here the asp.net mvc controllers are used by App1 pointing to the server: www.app1.com and asp.net web api2 controllers are used by another frontend angular app: App2 pointing to the server : www.app2.com
The complete deployment package for both App1 and App2 are hosted in IIS
Any request related to App1 is handled by www.app1.com and any api request related to App2 (Angular frontend) is handled by App1 only using IIS Rewrite rules at App2 level which redirect any api request to App1 only.
Now in this case when I tried to navigate to www.app1.com/swagger , I see it is loading the SwaggerUI for me, but when I tried to navigate to www.app2.com/swagger it is not working and instead of that it is loading the Angular frontend application
Here goes the App1 and App2 at IIS level:
Can anyone help me here by providing their guidance to fix this issue?
-
Cors error missing allow origin header. MailKit
I have
cors error missing allow origin header
error only on ONE post request. My CORS Policypublic void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => { builder.SetIsOriginAllowed(_ => true) .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); }); }
Every request work fine, but one POST request fails, it's really weird. Code in controller action which failed use MailKit and SMTP to send email, maybe that's cause