|
If you're adding the new dates from within the onselect event, you'll probably want to extract that to a separate function:
var onStartDateSelect = function(dateText){
...
var $wrapper = $(this).parent().parent();
addNewDate($wrapper);
};
var onEndDateSelect = function(dateText){
...
var $wrapper = $(this).parent().parent();
addNewDate($wrapper);
};
var addNewDate = function($wrapper){
count++;
var tmpHTML = '...';
var $newField = $(tmpHTML).appendTo($wrapper);
$newField.find('.parameterDateRangePicker.clearable.start').datepicker({
changeMonth: true,
changeYear: true,
onSelect: onStartDateSelect
});
$newField.find('.parameterDateRangePicker.clearable.end').datepicker({
changeMonth: true,
changeYear: true,
onSelect: onEndDateSelect
});
};
$('.parameterDateRangePicker.clearable.start').datepicker({
changeMonth: true,
changeYear: true,
onSelect: onStartDateSelect
});
$('.parameterDateRangePicker.clearable.end').datepicker({
changeMonth: true,
changeYear: true,
onSelect: onEndDateSelect
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sure my friend
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hello,
I am modifying an existing website. There is a nice feature where on one of the pages, if multiple images are returned by a datasource associated with a repeater control, the images can be swapped out by the user by clicking on either a left or right arrow which appears on the image. I wish to make the left and right arrows invisible if the repeater only has one image, as there is no ability to swap images when there is just a single image. Unfortunately, I can't figure out how to work this.
A simplified example of the ASP.NET code resembles this:
[ div outsidecontrols]
[ div class="arrow-left">< / div ]
[ div class="arrow-right">< / div ]
[ /div]
[asp:Repeater ID="Images" runat="server">
[div class="slide-image">
[img src="<%#Container.DataItem("Image_Name")%"/>
(In the interest of conveying where the div tags are for the left and right arrows, I have had to change some of the tags to use square brackets, as apparently if it looks like real code this forum tries to really put div tags in the comments.)
There is more to the code, but this is essentially what I am looking at. If I could get a record count of the repeater control, then I could conceivably hide the arrow controls if there was only one image. Something like this:
<asp:repeater id="Images" runat="server">
If #Container.DataItem.System.Data.DataRowView.Table.Rows.Count = 1 then
div.arrow-right.visible = false
div.arrow-left.visible = false
end if
Unfortunately, so far I can't get the record count of the data source feeding the repeater control with images. I also can't figure out how to make the left and right arrow div controls invisible after the repeater statement is encountered.
Does anyone have any suggestions about how to conditionally hide outer div controls based on the record count for a data source that is used by a repeater control to populate images? Does anyone know how to find the record count for a data source used by a repeater control?
Thanks,
|
|
|
|
|
Something like this should work:
<asp:Placeholder id="imageControls" runat="server" visible="false">
<div outsidecontrols>
<div class="arrow-left"></div>
<div class="arrow-right"></div>
</div>
</asp:Placeholder>
<asp:Repeater id="Images" runat="server" OnDataBound="Images_DataBound">
<ItemTemplate>
...
</ItemTemplate>
</asp:Repeater>
protected void Images_DataBound(object sender, EventArgs e)
{
imageControls.Visible = Images.Items.Count > 1;
}
NB: To format your code, you need to wrap it in <pre>...</pre> tags, and HTML-encode any special characters. [< ⇒ < | > ⇒ > | & ⇒ & ]
The "code" button on the toolbar should do this for you, or you could use the list of "Paste as" options that pops up when you paste your code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard, I think your idea of using a Placeholder control to wrap around the div tags, and setting the visibility of this control based on the record count of the repeater control is really nice. Unfortunately, I haven't got it to work yet.
First, I got an error trying to set an "OnDataBound" method for the repeater control. After some investigation, I tried using "OnItemDataBound."
Later, I get this compilation error: "Images_DataBound' is not a member of 'ASP.folder_page_aspx'. (The web page is under this directory structure: folder\page.aspx ). I have experimented with using your C# Images_Databound procedure, as well as using what I believe is an ASP.NET equivalent. I don't understand the error message "is not a member of 'ASP.folder_page.aspx'. I have looked through the project and don't see a web page with that name. I think the compilation error is using the folder I am under ("folder") adding an underscore and reporting there is a problem with ASP.folder_page.aspx.
I still like the placeholder control and setting the visible tag for the div tags beneath it to false. I also like trying to set those visible tags to true with a procedure that follows the closing repeater tag. I plan to keep on tinkering with this. Thanks again for your ideas. 
|
|
|
|
|
Richard, after tinkering further I finally got it to work! Thanks so much for your idea about using a placeholder to encapsulate the outer div tags.
First, the method is OnItemDataBound:
<asp: Repeater ... OnItemDataBind="Images_LeftRightControls">
If anyone is wondering how I get the record count of the Repeater control, in the code behind file (i.e., myFile.aspx.vb):
Sub Images_LeftRightControls(sender As Object, e As EventArgs)
Dim myCount As Integer
Dim myDataSource As System.Data.DataSet
Dim myTables As System.Data.DataTableCollection
Dim myList As System.Collections.ArrayList
myDataSource = sender.DataSource
myTables = myDataSource.Tables
myCount = myTables(0).Rows.Count
imageControls.Visible = myCount > [One--why can't I put a 1 here?]
End Sub
Thanks again, Richard! 
|
|
|
|
|
Sorry, I thought the repeater fired an event when it had finished binding to the data, but it looks like it doesn't.
The ItemDataBound event will fire for every item in the source data, which might cause problems.
You might want to consider using the ListView[^] instead. It's a lot more powerful than the Repeater , and it does have a DataBound event.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
|
I have two tabs:Customer and Contract. When I land on the page I want to show the Customer tab info but with my current code I'm unable to get it to work.
aspx
<nav id="spy">
<ul class="sidebar-nav nav">
<li><a href="javascript:void(0)" class="tablinks" onclick="openCity(event, 'Customer')">Customer</a></li>
<li><a href="javascript:void(0)" class="tablinks" onclick="openCity(event, 'Contract')">Contract</a></li>
</ul>
</nav>
<div class="col-sm-8" style="margin-left: 0px; width: 711px;">
<div class="row">
<div class="col-md-12 well tabcontent" id="Customer" style="width:546px">
<legend >Customer Selection</legend>
<div class="row">
<div class="col-md-5 spacing">Customer Source Code:</div>
<%----%>
<div class="col-md-4"">832 - NASA</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Customer Code:</div>
<%----%>
<div class="col-md-4">555</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Name:</div>
<%----%>
<div class="col-md-4">Aeronautics Lab</div>
</div>
<div class="row">
<div class="col-md-5 spacing">City:</div>
<%----%>
<div class="col-md-4">Houston</div>
</div>
<div class="row">
<div class="col-md-5 spacing">State:</div>
<%----%>
<div class="col-md-4">Texas</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Zip:</div>
<%----%>
<div class="col-md-4">10001</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 well hi tabcontent" style="width:546px;" id="Contract">
<legend >Contract Information</legend>
<div class="row">
<div class="col-md-5 spacing">Nasa Control Number:</div>
<div class="col-md-4">4416367</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Prime Contact Number<span style="color:red">*</span>:</div>
<div class="col-md-4">4416367</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Contract Start Date:</div>
<div class="col-md-4">10/30/2016</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Face Value of Contact<span style="color:red">*</span>:</div>
<div class="col-md-4">10/30/2016</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Contract End Item or Service:</div>
<div class="col-md-4">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Authorize Redelegation<span style="color:red">*</span>:</div>
<div class="col-md-4">YES</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Estimated LOD Completion Date<span style="color:red">*</span>:</div>
<div class="col-md-4">10/30/2016</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Is your LOD ONLY for one specific Purchase Order or Delivery Order:</div>
<div class="col-md-4">No</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Contracting Officer:</div>
<div class="col-md-4">John G. Doe</div>
</div>
<div class="row">
<div class="col-md-5 spacing">Date LOD Signed by Customer/Contracting Officer<span style="color:red">*</span>:</div>
<div class="col-md-4">08/11/2016</div>
</div>
</div>
</div>
js
$(document).ready(function(){
$(".custinfo").toggleClass("active");
$("#custinfo").show();
$("#continfo").hide();
$("#prime").hide();
var setHeight = $("#custinfo").outerHeight();
$("#spy").css('height', setHeight);
$(".sidebar-nav").css('height', setHeight);
$('#popover-button').popover({
html: true,
trigger: "hover",
content: function(){
return $('#popover-content').html();
}
});
$('#popover-button').click(function () {
$('.modal').modal('show');
$('#popover-content').popover('hide');
});
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("active");
});
$(".custinfo").click(function(e) {
e.preventDefault();
$("#custinfo").show();
$("#continfo").hide();
$("#prime").hide();
var setHeight = $("#custinfo").outerHeight();
$("#spy").css('height', setHeight);
$(".sidebar-nav").css('height', setHeight);
});
$(".continfo").click(function(e) {
e.preventDefault();
$("#custinfo").hide();
$(".custinfo").removeClass("active");
$("#continfo").show();
$("#prime").hide();
var setHeight = $("#continfo").outerHeight();
$("#spy").css('height', setHeight);
$(".sidebar-nav").css('height', setHeight);
});
$('body').scrollspy({ target: '#spy', offset:80});
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
$(window).bind('resize', function(){
});
|
|
|
|
|
I am dynamically creating a PDf in memory and sending a PDF attachment via email.
This works fine.
What I am having problem with is presenting the data in the format management wants.
For instance, they would want the layout in following format:
John Doe 12345
Employee Name Employee ID
john doe
Signature
11/04/2016
Date
How do I fix the code below to accomplish this?
Thanks in advance
I have modified my request and narrowed the help I need to one specific issue.
I need to lay out the results to look similar to this sample below:
<pre><pre lang="PHP"> John Doe 12345
Employee Name Employee ID
john doe
Signature
11/04/2016
Date
So far, everything is wrapping to one column.
I am using stringbuilder.
How do I fix this?
Private Sub SendPDFEmail(dtb As DataTable)
Using sw As New StringWriter()
Using hw As New HtmlTextWriter(sw)
Dim FullName As String = txtFullName.Text
Dim user As String = txtUserName.Text
Dim signedName As String = txtSignature.Text
Dim lDate As String = txtDate.Text
Dim sb As New StringBuilder()
sb.Append("<table border = '0'>")
sb.Append("<tr>")
For Each column As DataColumn In dtb.Columns
sb.Append("<th style = 'background-color: #ffffff;color:#000000'>")
sb.Append(column.ColumnName)
sb.Append("</th>")
Next
sb.Append("</tr>")
For Each row As DataRow In dtb.Rows
sb.Append("<tr>")
For Each column As DataColumn In dtb.Columns
sb.Append("<td>")
sb.Append(row(column))
sb.Append("</td>")
Next
sb.Append("</tr>")
Next
sb.Append("</table>")
sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>")
sb.Append("<tr><td align='center' style='background-color: #ffffff' colspan = '1'></td></tr>")
sb.Append("<tr><td colspan = '3'>")
sb.Append("" & FullName & "</td><td>" & user & "</td></tr>")
sb.Append("<tr><td>Employee ID: </td><td>Employee Signature: ")
sb.Append("</td></tr><tr><td colspan = '3'>")
sb.Append("" & signedName & "")
sb.Append("</td><td> </td></tr><tr><td>Employee Signature")
sb.Append("</td><td> </td></tr>")
sb.Append("<tr><td colspan = '2'>" & lDate & "</td><td> </td></tr>")
sb.Append("<tr><td colspan = '2'>Date :</td><td> </td>")
sb.Append("</tr>")
sb.Append("</table>")
sb.Append("<br />")
modified 5-Nov-16 8:25am.
|
|
|
|
|
That looks like you are just creating one long string. Where is the code that generates a PDF file?
|
|
|
|
|
UDPATE::
This issue has now been resolved.
modified 5-Nov-16 14:39pm.
|
|
|
|
|
how to dynamically generate a SQL server query based on the application server received input from the user
|
|
|
|
|
Probably by writing some code.
|
|
|
|
|
Hello
I am getting the following error:
System.Data.OleDb.OleDbException: Operation must use an updateable query.
when I type in a valid user's email (he exists in the Access mdb) on this page:
forgotten password[^]
I have read a couple of articles on this question, including this one:
Solve Operation Must Use an Updateable Query Error in Access[^]
and have set my permissions accordingly. The folder that houses my Access database, App_Data, has the following permissions: SYSTEM, Steve, and Administrators have full permissions, and Home Users have all permissions apart from Full Control.
[^]
After compiling my project, that folder is now on the server of my Web hosting service and these are the file permissions of App_Data on the server:
[^]
However, I am still getting the same error. Do I need to do anything in the Control Panel of the server, too (I have a Web hosting service) or is what I have already enough>
Thank you.
|
|
|
|
|
When you use an Access database, the code needs to be able to create, modify and delete files in the directory containing the .mdb file.
In ASP.NET, the server-side code does not run as a normal user. Depending on the settings for your AppPool, it will either run as a specific user for that pool, or as the Network Service account.
On your local machine, you need to give the IIS_IUSRS group "modify" access to the folder. This group contains all of the AppPool-specific users created by IIS.
You'll need to contact your hosting company to find out what permissions you need to apply there.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I want to implement Crud operation with generic repository ,unit of work, repository and service layer. I did all the layers but i don't know how to implement it in the controller.Please Help!!
|
|
|
|
|
This reads like the start of a bad joke.
Seriously, though, show us what your issue is (such as how you have your UoW/Repository defined) or you'll never get help with it.
And if I might humbly suggest: if you're not prepared to do query your DAL from your business layer, please don't over-reach on your architectural concerns. Reel it back until it clicks.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
You wrote a layered generic repo that supports UoW...but you don't know how to call your code from a controller? I don't understand how you can develop such a thing yet don't know how to call one class from another?
|
|
|
|
|
Hi guys, I´m new to ASP.NET Core and EF Core and I have the following problem:
I have two related objects, Goals and Months, Goals got the foreign key of Months, and when I try to save the data of goals I got a foreign key error because the value of MonthId is 0, but when I create the select in the HTML I got correct code value.
Description of the error:
SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint FK_Goals_MonthId;. The conflict occurred in database Portal_RNT, table dbo.Months , column MonthId;.
The statement has been terminated.
Here is the code:
HTML
@model ProjectName.Models.Goals
<div>
<form asp-controller="Goals" asp-action="Create">
Other form elements
<select name="months" asp-for="MonthId" class="form-control" asp-items="ViewBag.Months">
</select>
<input type="submit" value="Save" class="btn btn-primary" />
</form>
</div>
Goals Model
public class Goals
{
[Display(Name = "Code")]
public Int32 GoalId { get; set; }
public String GoalName{ get; set; }
public Months Month{ get; set; }
public Int32 MonthId{ get; set; }
....
Other properties
}
Month Model
public class Months
{
[Key]
[Display(Name = "Code")]
public Int32 MonthId { get; set; }
[Display(Name = "Designation")]
public String Designation{ get; set; }
}
Goals Controller
public IActionResult Create(Goals goal)
{
if (ModelState.IsValid)
{
_context.Goals.Add(goal);
_context.SaveChanges();
}
return View("~/../Create.cshtml");
}
Best Regards
|
|
|
|
|
Hi all,
I'm working on reducing the amount of calls to the DB in the applications at our company. One issue that I'm seeing is that the same data is being used by the MVC Controller and the AngularJS controller and an individual call is being made to the DB for each.
I'd like to find a clean way to pass a model into the AngularJS controller when it loads. What suggestions would you have as far as setting this up?
Thanks!
|
|
|
|
|
The best way I've found to conceptualize a SPA is that it's 2 completely separate applications: one for UX/business and the other for data access/projections.
From that standpoint, the optimal backend is a service, which in the .NET world usually means WebAPI for data projected through HTML templates as managed by Angular. You shouldn't use your MVC controllers for any populated views; just get your templates with it (if you absolutely have to have the MVC controllers at all) and JsonResult responses for data access.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
So that is actually how it is currently set up. In this specific case though, I have a page that generates and displays a chart using a .NET tool called SpreadsheetGear. The appearance of the chart is dependent on settings the user has submitted (which we store in the DB). So the Action that generates this chart obviously needs access to that data. However, this page has a modal window that you can open that has an interface where the user can change the settings (AngularJS). We need to prepopulate this with the current settings, so the Javascript needs the same set of data as the Action that generated the chart.
Hopefully I did a good enough job describing the setup. This seems like a decent candidate for a case where an Action and the JS need access to the same data. How would you recommend dealing with this? I'm hoping to not have to execute the same query on the DB twice.
|
|
|
|
|