How to get rid of boxing in css of ASP.NET web application?
.Iam new to making a ASP.NET Core web application and i have most of it finished however I've come across a styling issue,where I cannot fit the size of some of the elements to the fill width of the screen.Ive tried the css + html code separately to the ASP.NET and it works fine. Thanks.
https://ibb.co/g7dx3gC Link to ASP.NET version
https://ibb.co/93JCvKB Picture of the Html/CSS of the ASP.NET
https://ibb.co/9rVDKvy Working one with elements taking full screen size
See also questions close to this topic
-
Filter items in a listbox that have been added with json
Well I'm trying to list items that are from listbox created with UserControl and the text properties are defined with a json file.
This is my .json file:
{ "Games": { "Quantity": 2, "Title0": "SomeGame1", "Description0": "Fps game", "Image0": "Some image link", "Link0": "GameStore.com/Somegame1", "Title1": "SomeGame2", "Description1": "RPG game", "Image1": "Some image link", "Link1": "GameStore.com/Somegame2", } }
This is the code to load the games as items in the listbox:
string JsonFile = Environment.CurrentDirectory @"\Test.json"; dynamic jasonfile = JsonConvert.DeserializeObject(JsonFile); GameUserControl[] Games = new GameUserControl[jasonfile["Games"]["Quantidade"]]; for (int quantity= 0; quantity < Games.Length; quantity++) { Games[quantity] = new GameUserControl(); Games[quantity].Descrição.Content = (jasonfile["Games"]["Title" + quantity]); Games[quantity].jog = (jasonfile["Games"]["Titulo" + quantity]); Games[quantity].lin = (jasonfile["Games"]["Link" + quantity]); string image = jasonfile["Games"]["Image" + quantity]; Games[quantity].imag = new ImageBrush(new BitmapImage(new Uri(image, UriKind.Absolute))); GamesListBox.Items.Add(Games[quantity]); }
This is the code I used in a textbox to try to filter:
if (CollectionViewSource.GetDefaultView(GamesListBox.Items) != null) CollectionViewSource.GetDefaultView(GamesListBox.Items).Filter = (o) => { return o.ToString().ToLower().Contains(Search.Text.ToLower()); };
But it didn't work, the item names are always GameUserContro.Can someone help me?
-
Advantage of .Net Core over WCF for RESTful APIs
We are currently using WCF to create RESTful APIs, it is working fine and has an added advantage that it can be consumed via SOAP too if we ever need to. We have all our systems using Microsoft technologies.
There is no active development on WCF but the current functionality is working fine for us. However, I believe the recommended approach is to start using .Net core for RESTful services. What are the additional advantages .Net core offers over WCF (apart from being platform independent)?
-
Generic class type constraint with a generic class having another constraint
Let's say I have a generic class
public class G<T> { }
and I want to declare final class as
public class F<T> where T : G<T> { }
that seems to be possible, but what if I want to complicate the task and add a constraint to the class G like that
public class A { } public class DA : A { } public class DB : A { } public class G<T> where T : A { }
and finally I want to do this
public class F<T> where T : G<T> { }
that does not work, it says T has to be of type A which is understandable and it looks like I can rewrite it like this
public class F<T, U> where T : G<U> where U : A { }
but in this case the usage has a redundant declaration
public class DF : F<G<DA>, DA> { }
I have to repeat DA twice when using class F even though it is quite clear if I use G as a generic type the generic type of G is DA. Is there a way to avoid this redundancy?
-
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 add python variable (containing url in string), in HTML's img src? <img src=" " > in flask
i want to insert a python variable into html img src="" But i don't know how to insert the variable(contains string type url) into html's image src=" "
-
How do I make my container increase itself when the children increase?
I have this div.container in which I have a heading and a form. I have other pages with other forms too, but this container stays in just one height. I want the container to increase or decrease its height depending on my form. How do I make my container increase itself when the children increase?
* { margin: 0; padding: 0; font-family: Helvetica; } body { background-position: center; background-size: cover; background-position: center; background-size: cover; } h2 { font-family: Helvetica; text-align: center; margin-top: 50px; margin-bottom: 40px; color: #222; font-size: 28px; position: static; } .container { width: 940px; height: 500px; margin: 8% auto; background: #f3f6f7; border-radius: 7px; } .container form { width: 280px; } form input { margin-bottom: 9px; }
<div class="container"> <h2>Example</h2> <form> <input type="text" placeholder="First Name" required /> <input type="text" placeholder="Last Name" required /> <input type="text" placeholder="Phone Number" required /> <input type="text" placeholder="Google Meet ID" required /> <input type="text" placeholder="LinkedIn Profile" required /> <input type="text" placeholder="First Name" required /> <input type="text" placeholder="Last Name" required /> <input type="text" placeholder="Phone Number" required /> <input type="text" placeholder="Google Meet ID" required /> <input type="text" placeholder="LinkedIn Profile" required /> <input type="text" placeholder="First Name" required /> <input type="text" placeholder="Last Name" required /> <input type="text" placeholder="Phone Number" required /> <input type="text" placeholder="Google Meet ID" required /> <input type="text" placeholder="LinkedIn Profile" required /> <input type="text" placeholder="First Name" required /> <input type="text" placeholder="Last Name" required /> <input type="text" placeholder="Phone Number" required /> <input type="text" placeholder="Google Meet ID" required /> <input type="text" placeholder="LinkedIn Profile" required /> <div class="btn-box"> <button type="button">Back</button> <button type="button">Next</button> </div> </form> </div>
Also, how do I bring the form to the center?
-
How to set CSS/SCSS background-image property in Next JS?
I am working on a project using React and Next JS, and this is a glimpse of the file structure:
// other root folders... L pages L public L src L assets L image.svg // this is the image that I wanted to turn into a background of an element L components L styles L divider.module.scss // this is where I've added the background-image property
I've successfully imported images using the syntax
import image from '[file path]'
with various extensions with a custom web pack configuration from the official documentation. The next.config.js consisted of the following:module.exports = { webpack: (config) => { config.module.rules.push({ test: /\.(png|jpe?g|gif|svg)$/i, loader: 'file-loader', options: { name: '[name]_[hash].[ext]', publicPath: `/_next/static/assets`, outputPath: 'static/assets', }, }); return config; }, };
However, the problem is that images that are loaded using CSS/SCSS seem to raise this particular error:
XML Parsing Error: syntax error export default "[file path]";
. Can anyone kindly elaborate what is it that I'm doing wrong? Thank you. -
CodeIgniter CSS dissapears after clicking a link
So I'm using codeigniter, and after loading up my homepage from localhost, it works fine, but the second I click a link on the navbar the pages lose all css, even if I return to that same homepage through the navbar, all css is gone. my css file is in "./assets/css/". this is my code for css:
header.php has the following:
<link rel="stylesheet" href="assets/css/style.css">
all .html pages have the following at the beginning:
<?php $this->load->view('header'); $this->load->helper('url'); $base = base_url() . index_page(); $img_base = base_url()."assets/images/"; ?>
Sorry if you need more code please let me know.
-
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
-
Web App gets wrong IP after Windows Server upgrade
We cloned the servers, upgraded to a newer version of the OS (Windows 2012) which is compatible with the web app. However, when we placed those servers in production, only the one with the load balancer was being accessible through the IP. The other 4 were not because the load balancer was trying to redirect traffic to the local IP instead of the public ones. I don't know if this is information enough, but we can't seem to find the issue since the config of the web app is the same and the IIS didn't seem to have issues. Maybe the DNS? The IP's are the same.
-
User Permissions in a Decoupled Central File Service
So in my network, lets say I have 5 services, all of which require the ability to use files. In an old world app, i'd have implemented file management code each app/service. However, I am looking at implementing a central file service, which would sit on top of s3/gdrive/some other storage location. The 5 original services can talk to the file service if they need to read/write file contents, but they only need to concern themselves with business logic and not all the coding complexity of file systems.
The outside services/apps would pass a uid to the file service to get files. We would also create a tiny web applet to expose the file service on the web so that users in our network could load a file, if they had the file uid.
My issue, is that how do you implement a rich user access model within the file service ? Sure you can ensure that the user is logged in before granting them the file. How would people handle richer logic such as "user Bob can only access files for project 54 but not 56" ? here we have a business rule that is a thorn in the side of being able to decouple files from the apps.
Previously this would have been solved by :
app4.foobar.com/project/download/54
Because you're in app4, you have the contextual information to ensure bob gets that file but not 56.
Where as :
file.foobar.com/download/362390js03-25sgsg3-a3-2525
can't know what a project is, because that is part of the app4 domain model.
Thoughts?
-
How Display The Data on Page Load
I've been working on the Search CRUD using Google WebApp Script via watching a YouTube tutorial, I'm almost done but I'm stuck in a place I couldn't figure out to sort the issue.
I want to load the search field and the data on first page load. but based on this code I need to click on the Search Tab and then get the search field to find the data. How do I get rid of the Search Tab and get straight into the search bar and data.
Second Occurrence (After the Click)
My code
<!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> <style> .nav-link { cursor: pointer; } </style> </head> <body> <div class="container"> <ul class="nav nav-tabs"> <li class="nav-item"> <div class="nav-link"id="search-link">Search</div> </li> </ul> <div id="app"></div> <!-- Content here --> </div> <!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) --> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script> <script> var data; function loadView(options){ var id = typeof options.id === "undefined" ? "app" : options.id; var cb = typeof options.callback === "undefined" ? function(){} : options.callback; google.script.run.withSuccessHandler(function(html){ document.getElementById("app").innerHTML = html; typeof options.params === "undefined" ? cb() : cb(options.params); })[options.func](); } function setDataForSearch(){ google.script.run.withSuccessHandler(function(dataReturned){ data = dataReturned.slice(); }).getDataForSearch(); } function search(){ var searchinput = document.getElementById("searchinput").value.toString().toLowerCase().trim(); var searchWords = searchinput.split(/\s+/); var searchColumns = [0,1,2,3,4,5,6,7]; // and or var resultsArray = data.filter(function(r){ return searchWords.every(function(word){ return searchColumns.some(function(colIndex){ return r[colIndex].toString().toLowerCase().indexOf(word) !== -1 }); }); }); var searchResultsBox = document.getElementById("searchResults"); var templateBox = document.getElementById("rowTemplate"); var template = templateBox.content; searchResultsBox.innerHTML = ""; resultsArray.forEach(function(r){ var tr = template.cloneNode(true); var hinmokuColumn = tr.querySelector(".hinmoku"); var buhinCodeuColumn = tr.querySelector(".buhinCode"); var buhinNameColumn = tr.querySelector(".buhinName"); var hitsuyoColumn = tr.querySelector(".hitsuyo"); var genkaColumn = tr.querySelector(".genka"); var kobaiColumn = tr.querySelector(".kobai"); var sagakuColumn = tr.querySelector(".sagaku"); var kenshoColumn = tr.querySelector(".kensho"); hinmokuColumn.textContent = r[0]; buhinCodeuColumn.textContent = r[1]; buhinNameColumn.textContent = r[2]; hitsuyoColumn.textContent = r[3]; genkaColumn.textContent = r[4]; kobaiColumn.textContent = r[5]; sagakuColumn.textContent = r[6]; kenshoColumn.textContent = r[7]; searchResultsBox.appendChild(tr); }); } function loadSearchView(){ loadView({func:"loadSearchView", callback: setDataForSearch}); } document.getElementById("search-link").addEventListener("click",loadSearchView); function inputEventHandler(e){ if (e.target.matches("#searchinput")){ search(); } } document.getElementById("app").addEventListener("input",inputEventHandler); </script> </body> </html>
Server Side Code
function getDataForSearch(){ const ss = SpreadsheetApp.getActiveSpreadsheet(); const ws = ss.getSheetByName("Array"); return ws.getRange(2, 1, ws.getLastRow(),8).getValues(); }
I need to type letters in order to data display. Screen Shot 3