|
I have the following View:
<script>
$(document).ready(function () {
$('.profile_boxes').click(function () {
var val = $(this).attr('id');
$('.profile_boxes').css('background', '#fff');
$('.profile_boxes').css('border', '1px solid #ededed');
$("#" + val).css('background', '#f6f6f6');
$("#" + val).css('border', '1px solid #f55');
$.ajax({
url: '@Url.Action("RenderProfilePartials", "NewProfile")',
data: { 'profile': val },
cache: false,
type: "POST",
dataType: "html",
success: function (data, textStatus, XMLHttpRequest) {
console.log(val);
$('#profilePartials').html(data);
},
error: function (data, textStatus, XMLHttpRequest) {
console.log(data);
}
});
});
});
</script>
<div class="centering col-lg-6 logged_in_mainboxes">
<h2>What are you?</h2>
<div id="band" class="col-lg-4 profile_boxes">
<h3>Band</h3>
</div>
<div id="musican" class="col-lg-4 profile_boxes">
<h3>Musican</h3>
</div>
<div id="regular" class="col-lg-4 profile_boxes">
<h3>Regular</h3>
</div>
@Html.ValidationSummary(false)
<div id="profilePartials">
</div>
</div>
When you click on either Band, Musician or Regular, I partial view Is renderd:
<div id="band_info" class="col-lg-9 profileDesc">
<p>Maybe some information about the band profile here.....</p>
@using (Ajax.BeginForm("RegisterBand", "NewProfile", new AjaxOptions() { HttpMethod = "Post" }))
{
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-horizontal">
<div class="form-group">
Bandname
<div class="col-md-10">
@Html.EditorFor(x => x.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(x => x.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
Coverpicture
<div class="col-md-10">
@Html.EditorFor(x => x.CoverPicture, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(x => x.CoverPicture, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
Description
<div class="col-md-10">
@Html.EditorFor(x => x.Description, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(x => x.Description, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Spara" class="btn btn-success" />
</div>
</div>
</div>
}
</div>
Now I want to validate this forms with Ajaxoptions and unobtrusive. But when I hit Submit, the page Is reloaded and the partial views returned back.
I want it not reload, I want to make the validation without the reload.
Here Is my controller:
[HttpPost]
public ActionResult RegisterBand(BandProfileModel model)
{
if (ModelState.IsValid == false)
{
return PartialView("_BandRegisterPartial", model);
}
return View("Index");
}
I have enabled unobtrusive in web.config and all that stuff.
Anyone who can help me?
|
|
|
|
|
|
Other than manually setting up 64 ‘truth tables’, is there a more efficient method of finding the squares on a chessboard that a queen can not get too, given the queen is placed at random on the chessboard?
|
|
|
|
|
Depends on your interpretation of "efficient" and the whole scenario. If the queen is not the only piece on the board then you would have to check for "collisions" in any case. Calculating the fields that it can get to and then taking the complement of that would be my first approach.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Hi Sascha, The good news is if the queen can not get to a certain square, then “collisions” will not be an issue. I really did not want to have to recalculate the fields each time a queen is placed on the chessboard. I am still leaning toward sets of truth tables, but was wondering if there an easier method. Thanks for your post.
|
|
|
|
|
I'd say that the queen can't get to any square that isn't at a 45 degree angle. Meaning any square that isn't on one of these angles 0, 45, 90, 135, 180, 225, or 270 from the current position. Assuming you want to bring some math into the calculation.
Edit: Not sure this is more efficient. I think I'd set up an 8x8 grid and flag where she can get. What is not flagged is where she can't get.
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
Hi Ron, I have no problem with the same file / rank / diagonal for the queen being on. Just wanted to eliminate having to process that scenario if I can quickly eliminate her not being able to get to the square I am currently interested in. Thanks for your reply.
|
|
|
|
|
Member 12357747 wrote: Other than manually setting up 64 ‘truth tables’, is there a more efficient method of finding the squares on a chessboard that a queen can not get too, given the queen is placed at random on the chessboard? It depends on what you want to do with the "truth tables".
Member 12357747 wrote: Other than manually setting up 64 ‘truth tables’ What do you call "manually setting" ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Hi ppolymorphe. "manually setting" is not the right verbiage I should have used. I would write an algorithm which would generate 64 tables, each table consisting of 8X8 squares. The queen is placed on square 1 for the first table… and so forth until the last table… she is placed on square 64.
Each table has Boolean true/false squares. All I have to do is looked at the correct table depending what square she is on and the square I am interested in would return the correct Boolean value.
Thanks for your reply.
|
|
|
|
|
Once all tables prepared, there is nothing faster than loading the table.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Hi ppolymorphe. I will now have to write an algorithm is generate these tables. Nothing easy but doable. 64 bytes X 64 bytes: I will stick them in memory.
|
|
|
|
|
Bits might be more efficient: 64 bits fits in a single machine word on most machines these days, and the conversion from coordinates to mask is trivial:
long bitmask = ((long)1) << ((y << 3) + x); Where x and y are integer coordinates.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks OriginalGriff, I will try that and see how it works.
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It's not so bad, as suggested you can use bitboards (which will be useful when using them too, giving trivial intersection tests and so on), and because this is chess, this is all already known: chessprogramming - On an empty Board[^] gives the initialization routines for various attack masks, you can combine them here because you don't need the separate components.
|
|
|
|
|
Thanks Harold, I did not realize how extensive bit tables are being used.
|
|
|
|
|
Hi
I want to add a session in the webMethod. but it ignores it totally
[WebMethod (EnableSession = true)]
public string GetTasksCountWebMethod()
{
int result;
if (Session["tasks"] == "" || Session["tasks"]==null)
{
Session["tasks"] = result.ToString();
return result.ToString();
}
else
{
return Session["tasks"].ToString();
}
}
Thanks
|
|
|
|
|
How do you know it ignores it? I assume Session["tasks"] is null? Check Session.SessionID. Also, how are you calling the webmethod?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi all
I've been trying to add sql data base on my connention windows properties but
but the "select or enter database" option do not exsist.
ca som please help me to figure it out
|
|
|
|
|
You're going to have to describe what you're looking at, which windows and in what application. We can't see your screen or read your mind.
|
|
|
|
|
Hi sorry for the lake of information so i'am talking about visual studio. in my case vs2013.
And when i am trying to add sql server connection on my server explorer (right click )
The "Select or enter data base name " drop down list from Add connection windows property is missing. The only why to the add relevant connection is to modify connection and add a the intial catalog by manual. what should i do in order to avoid set the initial catalog manual on Add Connection windows
|
|
|
|
|
The first thing you get asked when "Adding Connection..." is to specify what kind of data source to use. You're telling the system what type of database engine you're connecting to, be Access, ODBC, SQL Server, Oracle, ... and which provider to use to get at it. Once you pick that THEN you get to pick the database server (if applicable) and database name.
|
|
|
|
|
Hello,
I want to add an application to windows firewall exception in Standard user without prompting for admin password.
I don't want to store my password of user who have admin privileges and later call it in standard user.
How can I achieve this ?
|
|
|
|
|
AFAIK, you can't.
And if you think about it, that's for good reasons.
If your app could change firewall settings without Admin privileges, then so could any other app - including a lot of nasty ones that would really like to open holes in your firewall as a side effect!
Be glad you can't - or half your system security would disappear overnight...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Yes, I got the same answer everywhere. But I got this doubt because of Tally.ERP 9.
I am using Tally.ERP 9 which is installed in Local server ( Requires admin privilege to install). When I access that application remotely in standard user the Tally.ERP 9 gets added to firewall exception in Local PC. (There is no common users in Server PC and Local PC)
How Tally.ERP 9 added without admin privileges ?
|
|
|
|