I would like to replace http://www.somewebsite.com programmaticaly when page loads.
Is it possible to do?
<head runat="server">
<title></title>
<link href="http://www.somewebsite.com/App_Themes/Blue/StyleSheet.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="www.somewebsite.com/inc/styles_ie.css" />
<![endif]-->
<link href="http://www.somewebsite.com/App_Themes/RedBlack/StyleSheet.css" type="text/css" rel="stylesheet" />
</head>
Here I found a really good example how to do it http://www.codeproject.com/Tips/523983/Adding-Styles-Dynamically-to-ASP-NET-Page-Header
Literal cssFile = new Literal()
{
Text = #"<link href=""" + Page.ResolveUrl(styleFilePath) +
#""" type=""text/css"" rel=""stylesheet""/>"
};
Page.Header.Controls.Add(cssFile);
Related
Ok, so I recently had an SEO audit done on my site and per the recommendations I added the Geo.txt, robots.txt, Schema.txt and sitemap.xml files to my root directory (not sure exactly if this is where these files go...) And now for some reason my page displays like there is no CSS file at all. Could adding one of these files affect that? Do I need to add the path to my CSS to one of the files? I will add my header section below.
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-L6BBJ36NQR"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-L6BBJ36NQR');
</script>
<asp:ContentPlaceHolder ID="contentHead" runat="server">
</asp:ContentPlaceHolder>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="keywords" content="Web Development Erie PA Application Custom Software Northwest PA" />
<link rel="manifest" href="site.webmanifest" />
<link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.ico" />
<!-- CSS here -->
<link href="" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="assets/css/owl.carousel.min.css" />
<link rel="stylesheet" href="assets/css/slicknav.css" />
<link rel="stylesheet" href="assets/css/flaticon.css" />
<link rel="stylesheet" href="assets/css/progressbar_barfiller.css" />
<link rel="stylesheet" href="assets/css/gijgo.css" />
<link rel="stylesheet" href="assets/css/animate.min.css" />
<link rel="stylesheet" href="assets/css/animated-headline.css" />
<link rel="stylesheet" href="assets/css/magnific-popup.css" />
<link rel="stylesheet" href="assets/css/themify-icons.css" />
<link rel="stylesheet" href="assets/css/slick.css" />
<link rel="stylesheet" href="assets/css/nice-select.css" />
<link rel="stylesheet" href="assets/css/style.css" />
</head>
The page is supposed to look like this:
Proper site look
But instead it looks like this:
Wrong site look
When I want to use a variable in a link (parameter) all js files throw console errors
When I remove the parameter from the link everything works fine
Page:
#page "/PollShow/{id:int}"
#code{
[Parameter]
public int Id { get; set; } = 1;
}
this is my _host.cshtml
#page "/"
#namespace Polls.Pages
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
#{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>SB Admin 2 - Dashboard</title>
<link href="~/css/sb-admin-2.css" rel="stylesheet" />
<link href="~/css/StyleSheet.css" rel="stylesheet" type="text/css" />
<!-- Custom fonts for this template-->
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<!-- Custom styles for this template-->
<link href="css/sb-admin-2.min.css" rel="stylesheet">
<!-- Custom styles for this page -->
<link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
</head>
<body id="page-top">
<component type="typeof(App)" render-mode="ServerPrerendered" />
<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>
<!-- Page level custom scripts -->
<script src="js/demo/datatables-demo.js"></script>
<script src="~/_framework/blazor.server.js"></script>
</body>
</html>
error console when i use link with parameter
enter image description here
You'll need to use the exacte same name for the parameter. Its case sensitive
#page "/PollShow/{Id:int}"
// Navigate to Account Managemnt window
Thread.Sleep(10000);
chrome_driver.FindElement(By.XPath("//*[#id='module-menu']/div/button")).Click();
Thread.Sleep(10000);
chrome_driver.FindElement(By.XPath("//*[#id='module-menu']/div/div/button[2]")).Click();
//*[#id="module-menu"]/div/div/button[2]
Thread.Sleep(20000);
IWebElement body = chrome_driver.FindElement(By.TagName("body"));
var result = chrome_driver.FindElement(By.TagName("body")).Text;
Console.WriteLine(result);
IWebElement Single_Acc_Add = chrome_driver.FindElement(By.XPath("//*[#id='single-add-button']/button/span"));
//chrome_driver.FindElement(By.LinkText("+ Add")).Click();
action.MoveToElement(Single_Acc_Add).Build().Perform();
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="/manifest.json">
<link rel="shortcut icon" href="/favicon.ico">
<title>PCR Universe</title>
<link href="/static/css/main.ed365ca1.css" rel="stylesheet">
</head>
<body>
<div
id="GLOBAL_INFO"
data-envvar="-siteminder"
data-clientname="universal-dashboard"
data-clientid="3027d708-26a2-4b63-a131-d672617f46f4"
data-domain="azurewebsites.net"
data-apienvvar="-siteminder"
data-apiname="universalwidgetservice"
data-apidomain="azurewebsites.net"
data-LOGINURL="https://universal-dashboard-siteminder.azurewebsites.net/authorize"
data-LOGOUTURL= './Logout.html'
data-ERRORPAGE= './LoginError.html'
data-ENCODEDCOOKIE= 'false'
data-USETOKENAUTH= 'false'
>
</div>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<script type="text/javascript" src="/static/js/main.84c386bd.js"></script>
</body>
</html>
I am working with selenium and came across a website which is not created with java script but react elements, how can i detect IWebElement when there are no html tags. Not able to detect them with link Text as well.
I have a HTML page that have an iframe. This iframe has a button. Which is one of the possibile ways to press that button?
I tried with javascript, but I didn't solve it...
Thank you in advance!
hey you can try to find that button id and handle the click event..
it will look something like this.
$('#youriframeid').contents().find('#yourbuttonid').click(function(){});
EDIT
Your main html page containing iframe.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.min.js" type="text/javascript"> </script>
<script>
$('#a').contents().find('#iframbtn').click(function(){alert("It Worked!")});
$('#a').contents().find('#iframbtn').trigger('click');
</script>
</head>
<iframe id="a" source="a.html">
</iframe>
</html>
Your second html page containing iframe mark up
<html>
<input type="button" id="iframbtn" value="clickme"/>
</html>
Try to use this:
$("#mainiframe").contents().find("someID").trigger("click");
Sample1.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function call(){
try{
document.frm.but.click();
}catch(e){
}
}
</script>
<BODY onload ="call()">
<iframe src="Sample2.html" name="frm" width=100 height=100 />
</BODY>
</HTML>
Sample2.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function called(){
alert("---DONE--");
}
</script>
<BODY>
<input type="button" name="but" value="submit" id="but" width=60 height=60 onclick="called()" />
</BODY>
</HTML>
Hope this helps you.
I am trying to open a jQueryMobile datebox in a dialog mode. I am trying to set the datebox to a default value but it just won't take it for some reason. Here is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>#PageData["Title"]</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.css" />
<link rel="stylesheet" href="#Href("/Styles/theme/mysite.min.css")" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<script src="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/i8n/jquery.mobile.datebox.i8n.en.js"></script>
</head>
<body>
<script type="text/javascript">
$('document').ready(function(){
//Setting start date value on pageload
$('#myqdate').value('2012-01-14');
$('#myqdate').datebox('refresh');
}
</script>
<form name="shiftform" id="shiftform" action="#Href("~/Account/QChanges.cshtml")" method="post">
<div data-role="fieldcontain">
<label for="myqdate">Date:</label>
<input name="myqdate" id="myqdate" type="date" value="" data-role="datebox" data-options='{"mode": "flipbox", "forceInheritTheme": true, "defaultDate":"2012-01-14"}'>
</div>
<input type="submit" value="Get Queue"/>
</form>
</body>
</html>
I would really appreciate help from experts.
Thanks
This should do it:
$('#myqdate').trigger('datebox', {'method':'set', 'value':'2012-01-14', 'date':new Date('2012-01-14')})
It seems that you should be using the "defaultValue" property instead of the "defaultDate" that is in the data-options of your posted code. No need for the script block.
try closing your function:
$('document').ready(function(){
//Setting start date value on pageload
$('#myqdate').value('2012-01-14');
$('#myqdate').datebox('refresh');
}
)};