I want to read source code from a website, however the Content is hidden ,example :
this code , that read by Firefox
**
<script type="text/javascript" src="http://stc.m.nixcdn.com/js/html5-player.0.1.js"></script>
<div class="player">
<div class="hide-html5">
<audio id="audio" controls="controls">
<source src="http://aredir.nixcdn.com/4872ac6dba1848a6300a022df6b76789/5357217a/NhacCuaTui854/LacDuong-PhamTruong-3025698.mp3" type="audio/mpeg" />
</audio>
</div>
<div id="play" class="play control">
</div>
<div id="progress">
<div id="progress_box">
<div id="load_progress" style="width:0px;">
<div class="hand-control" id="hand_progress" style="left:-7px;">
</div>
<div id="play_progress" style="width:0px;">
</div>
</div>
</div>
</div>
<div id="play_time">
<span id="current_time_display">00:00</span>
</div>
</div>
<script type="text/javascript">
bodyLoaded();
document.getElementById("audio").addEventListener("ended",
function() {
playAudio();
}, false);
</script>
**
C# code :
using(WebClient client = new WebClient())
{
data = client.DownloadString(url);
}
but Source code , that downloaded not have the content.
I using c#. Thanks.
Related
I have a page in ASP.NET Core 3.0 with RAZOR(no MVC), with a partial page loaded with AJAX; load works well but validation rules no. Validation with "required" notation on otherinput fields also works well.
This is my main page:
<a class="nav-link showposition text-dark text-center p-0 collapsed" id="ShowPosition" href='ShowPosition'>#item.Sale_Order_Position</a>
<div class="card shadow mb-4 collapse" aria-labelledby="ShowPosition">
<div id="DetailContents">
</div>
</div>
<script>
jQuery(function($) {
$('.showposition').on('click', function (e) {
e.preventDefault();
$.ajax({
url: $(this).attr('href'),
type: 'GET',
cache: false,
headers: {
RequestVerificationToken: $('input:hidden[name="__RequestVerificationToken"]').val()
}
}).done(function(result) {
$('#DetailContents').html(result);
//Setup Position details
$('#SavePositionForm').SetupPositionDetails();
});
});
(function( $ ){
$.fn.SetupPositionDetails = function () {
$("#SavePositionForm").removeData("validator");
$("#SavePositionForm").removeData("unobtrusiveValidator");
$.validator.unobtrusive.parse("#SavePositionForm");
$("#SavePositionForm").validate({
debug: true,
rules: {
inp_NetPrice: {
required: true
}
}
});
};
})(jQuery);
});
</script>
And this is my Partial View:
<form id="SavePositionForm" class="needs-validation" novalidate>
<div class="col-sm-12 col-md-12 col-lg-6 col-xl-6">
<div class="row">
<div class="col div_image pl-0">
<label class="bg-white"><i class="fr fa-newspaper mr-2"></i><localize>Net price</localize></label>
</div>
<div class="col-sm-6 col-md-6">
<input class="form-control form-control-sm" type="number" step="any" name="inp_NetPrice" id="inp_NetPrice" asp-for="#Model.Item1.Net_Price" value="#Model.Item1.Net_Price"/>
</div>
</div>
</div>
</form>
The problem is "inp_NetPrice" validation not working.
I have also try this script, in main partial page(i know, it's not a good idea to put script in partial pages but I would like to try) without success:
$(document).ready(function () {
$("#SavePositionForm").validate({
debug: true,
rules: {
inp_NetPrice: {
required: true
}
}
});
$("#SavePositionForm").removeData("validator");
$("#SavePositionForm").removeData("unobtrusiveValidator");
$.validator.unobtrusive.parse("#SavePositionForm");
});
Any suggestions?
Thanks.
EDIT:
Generated HTML:
<div class="col-sm-12 col-md-12 col-lg-6 col-xl-6">
<div class="row">
<div class="col div_image pl-0">
<label class="bg-white"><i class="fa fa-newspaper mr-2"></i>Net price</label>
</div>
<div class="col-sm-6 col-md-6">
<input class="form-control form-control-sm" id="inp_NetPrice" name="inp_NetPrice" value="" type="number" step="any">
</div>
</div>
</div>
Problem fixed removing
name="inp_NetPrice"
because i have
name="inp_NetPrice" id="inp_NetPrice" asp-for="#Model.Item1.Net_Price"
I'm stuck more than 48hours on this problem.
I made a new user dashboard interface and I'm trying to display "_UserList" but the program considers it NULL. I don't understand why. If I look in SSMS there are data in "_UserList".
I know how to overcome this error by checking if #Html.Partial((string)ViewData["_UserList"]) is NULL. But this is not my problem. I don't understand why it is considered NULL.
Index.cshtml
<div class="dashboard-icons">
#Html.Partial((string)ViewData["_UserList"])
</div>
_UserList.cshtml
#using LIB.BusinessObjects
#if (((Dictionary<long, User>)ViewData["List"]).Count > 0)
{
<script type="text/javascript">
var gLatestDashboardId = #(((Dictionary<long, LIB.BusinessObjects.User>)ViewData["List"]).Values.First(i => i.Id>0).Id);
var gDashboardItemsCount = #(((Dictionary<long, LIB.BusinessObjects.User>)ViewData["List"]).Count);
</script>
<form class="table-widget">
<div class="dashboard-ico">
<div class="outer-ico">
<div class="widget-caption">
#MedCore.Helpers.T.Str("Users", "DashBoard", "Utilizatori sistemului")
</div>
<div class="data-grid-container">
<div class="data-grid">
<div class="data-grid-title-row">
<div class="data-grid-title">N</div>
<div class="data-grid-title">Login</div>
<div class="data-grid-title">#MedCore.Helpers.T.Str("Name", "DashBoard", "Nume")</div>
<div class="data-grid-title">#MedCore.Helpers.T.Str("LastLogin", "DashBoard", "Ultimul login")</div>
<div class="data-grid-title">#MedCore.Helpers.T.Str("DateCreated", "DashBoard", "Creat la")</div>
</div>
#Html.Partial("Controls/_UsersRows")
</div>
</div>
</div>
</div>
<div class="clear" style="height:1px"></div>
</form>
}
HTML Form sends POST request more than one. I am using jquery.unobtrusive-ajax.js for async connection.
When I submit the form request has been sent to server two times. These two connections' details are listed in the Browser's Network -> XHR tab.
Thank you for your suggestions and helps.
My HTML form and my JS files as follows:
JS
<script src="/assets/content/js/jquery.unobtrusive-ajax.js"></script>
<script src="/assets/global/scripts/datatable.js" type="text/javascript"></script>
<script src="/assets/global/plugins/datatables/datatables.min.js" type="text/javascript"></script>
<script src="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.js" type="text/javascript"></script>
<script src="/assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js" type="text/javascript"></script>
<script src="/assets/global/plugins/bootstrap-toastr/toastr.min.js" type="text/javascript"></script>
<script src="/assets/content/js/jquery.unobtrusive-ajax.js"></script>
HTML Form
#using (Ajax.BeginForm("UpdateDocument", "Document",
new AjaxOptions()
{
HttpMethod = "POST",
OnBegin = "Document.documentUpdateBegin",
OnSuccess = "Document.documentUpdateSuccess",
OnFailure = "Document.documentUpdateFailure"
}))
{
<div class="form-body">
<input type="hidden" name="ID" value="#Model.DocumentItem.ID" />
<div class="form-group form-md-line-input form-md-floating-label">
<input type="text"
class="form-control"
name="Title" id="title"
autocomplete="off"
maxlength="250"
value="#Model.DocumentItem.Title"
required="required" />
<label for="title_value">Title</label>
<span class="help-block">Max 250 characters</span>
</div>
<div class="form-group form-md-line-input form-md-floating-label">
<label class="control-label col-md-2"
style="padding-left: 0px; margin: 5px 0px; color: #888;">
Durum</label>
<div class="col-md-2">
#Html.CheckBox("IsActive", Model.DocumentItem.IsActive,
new
{
#class = "make-switch",
id = "is_active",
data_on_text = " Aktif ",
data_off_text = " Pasif "
})
</div>
</div>
</div>
<div class="form-actions noborder margin-top-20">
<div class="col-md-2">
<button type="submit" class="btn btn-block blue">UPDATE</button>
</div>
</div>
}
I found the solution.
There are two javascript jquery.unobtrusive-ajax.js file declaration in JS section.
After I removed the second <script src="/assets/content/js/jquery.unobtrusive-ajax.js"></script> problem is solved.
I want to append data to the repeater, the repeater has some data already on page load. But i want to remaing load data while Scrolling Page down.
<script type="text/javascript">
$(window).scroll(function () {
if ($(window).scrollTop() + $(window).height() == $(document).height()) {
showData();
}
});
function showData() {
PageMethods.getData(onSuccess, onError); // getData is a page webmethod thats return five record in json string.
function onSuccess(data) {
alert(data); // data has all five record.
}
function onError(data) {
alert('Problem');
}
}
</script>
.NET
<div id="Posts" class="container-fluid padded">
<asp:Repeater ID="PostsRepeater" runat="server">
<ItemTemplate>
<section>
<div class="col-md-2">
<img src="images/" <%#("ImagePath") %> alt="<%#Eval("username") %>" class="img-circle img-responsive" />
</div>
<div class="col-md-10">
<div>
<b><%#Eval("username") %></b><p><span class="glyphicon glyphicon-time"></span>Posted on Feb <%#Eval("CreationDate") %></p>
</div>
<hr>
<p><%#Eval("Status") %></p>
<img src="images/1451285316491.jpg" class="img-responsive">
</div>
<div class="row commentbox">
<div class="col-sm-2">
<div class="thumbnail">
<img class="img-responsive user-photo img-circle" src="images/1451285316491.jpg">
</div>
<!-- /thumbnail -->
</div>
<!-- /col-sm-1 -->
<div class="col-sm-10">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Ali</strong> <span class="text-muted">commented 5 days ago</span>
</div>
<div class="panel-body">
This Is awsome post
</div>
<!-- /panel-body -->
</div>
<!-- /panel panel-default -->
</div>
<!-- /col-sm-6 -->
</div>
<!-- /row commentbox -->
</section>
</ItemTemplate>
</asp:Repeater>
<img id="loader" class="img-responsive col-md-offset-4" alt="" src="images/loading.gif" style="display:none" />
</div>
On window scroll, you can make a jQuery Ajax call which returns data and on success method get the response and bind it to your parent Div Posts (i.e. repeator control)
Edited: Code to bind data .i.e( Ajax success method)
function OnSuccess(response) {
var items = response.d;
var fragment='';
$.each(items, function (index, val) {
var aData_imgSRC= val.imgSRC;
var aData_USERNAME= val.USERNAME;
// .....
fragment += "<section> <div class='col-md-2'> <img src='"+aData_imgSRC+"' class='img-circle img-responsive' /> </div> <div class='col-md-10'> <div> <b>"+aData_USERNAME+"</b><p><span class='glyphicon glyphicon-time'></span>Posted on Feb "+aData_Date+"></p> </div> <hr> <p>"+aData_Status+"</p> <img src='images/1451285316491.jpg' class='img-responsive'></div> </section>";
});
$('#Posts').append(fragment);
}
I have six div tags in my project and a hidden field. On mouse-over of this each div I want to get the value of div using hidden field. Is there a way out for this?
Below is my code:
<div class="item user">
<h2>qhse</h2>
<div id='qhse' class="qhse" runat="server" >
</div>
</div>
<div class="item home">
<h2>policies</h2>
<div id='hexa' class="hexa" runat="server" >
</div>
</div>
<div class="item shop">
<h2>procedures</h2>
<div id='policies' class="policies" runat="server">
</div>
</div >
<div class="item camera">
<h2>certificates</h2>
<div id='certificates' class="certificates" runat="server" >
</div>
</div >
<div class="item fav">
<h2>forms</h2>
<div id='forms' class="forms" runat="server" >
</div>
</div >
<div class="item last">
<h2>hexa</h2>
<div id='procedures' class="procedures" runat="server" >
</div>
</div >
</div>
I wish to get the id of each div in hidden field using javascript.
Javascript
$(function () {
$('#nav > div').hover(function () {
var $this = $(this);
$this.find('div').stop().animate({
document.getElementById("<%= hdnSelected.ClientID %>").value = "Policies";
});
But doing this method I am getting id of only one div. I need to get id's of all div's.
Thanks
Try this
$(function(){
var field = $('#<%= hdnSelected.ClientID %>');
$('#nav').on('mouseover', '.item > div[id]', function() {
field.val(this.id);
});
});