|
Hello experts,
I hope someone would be able to help me with this.
I have spent entire yesterday trying to figure this out but it still not working correctly.
When data is sent to PDF using stringbuilder and itextsharp, the results look like this:
http://www.wilogincometax.com/bad.png[^]
As you can see from the picture above, if either Employee Name or the value of Employee Name is longer than the other, the Employee ID and the value are mis-aligned.
I tried using fixed width so I can achieve results like below where both Employee Name and Employee ID are aligned correctly no matter the size of the length.
This is what we would like[^]
I am not having much luck with these two lines:
sb.AppendLine(String.Format("{0, -50}{1, -20}", "" & FullName & "", "" & user & "
"))
sb.AppendLine(String.Format("{0, -50}{1, -20}", "Employee Name", "Employee ID"))
entire code below:
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 System.Text.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><br>")
sb.Append("<br><br><br>")
sb.Append("<table width='100%' cellspacing='0' cellpadding='0'>")
sb.Append("<tr><td>")
sb.AppendLine(String.Format("{0, -50}{1, -20}", "" & FullName & "", "" & user & "<br>"))
sb.AppendLine(String.Format("{0, -50}{1, -20}", "Employee Name", "Employee ID"))
sb.Append("</td></tr>")
sb.Append("tr><td>")
sb.Append("" & signedName & " <br>Employee Signature")
sb.Append("</td></tr>")
sb.Append("<tr><td>" & lDate & " <br>Date</td></tr>")
sb.Append("</table>")
sb.Append("<br />")
I even tried using Module Extension that I googled up yesterday:
Module StringExtensions
<Extension()> _
Public Function AsFixedWidth(ByVal value As String, ByVal desiredLength As Integer) As String
Return value.PadRight(desiredLength).Substring(0, desiredLength)
End Function
End Module
According to the article, it is used with this
b.AppendFixed(s, 20) but I could not figure out how to fit this into my code.
Everything else works great except this.
Any help is greatly appreciated. Not your problem but this is going LIVE today.
|
|
|
|
|
Hi all,
We have a team that's developing an ASP.Net application, as we are new to ASP.Net MVC application, Changing the Web Configs became difficult while deploying as some times it is messing up for different environments. I want to have better approach for implementing this, I suggested for the Custom Config sections, but somebody from team suggested me that Microsoft in ASP.Net MVC automatically takes care of it by using debug and release config files, is it true. Or is there any better and automatic approach for implementing the publishing or deploying an ASP.Net MVC application without messing up with the Environment.
Please give me some advice, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Realistically, the web.config is the local administrator's responsibility, not the developers.
Yes, there are debug/release web.config options. In my experience, the debug should have your debug environment variables (manual settings for frequent-build projects == pointless) and sanitize debug data from the production version. Make sure the documents indicate the required fields in the web.config, and let the System Admin handle it, that's what they're there for.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
How about I have Custom Configuration then at one place in the AppConfig I define the Environment
<add key="Environment" value="Dev" />
<configSections>
<pre>
<section name="Dev" type="System.Configuration.SingleTagSectionHandler" />
<section name="Prod" type="System.Configuration.SingleTagSectionHandler" />
, so that when I set this to Dev then it will load the Dev Config section and when we set the Environment to Prod then it will load the Prod Config Section settings. This is what I have suggested so that there is less chance of confusion means, unexpectedly data won't go from here to there and only in one place we need to change so it would become easy for the Developer only one problem is sometimes when Developer doesn't have to know the Prod Settings then it will be a Problem. But in most of the cases developers only give Config files to the admin people.
If there are any better suggestions I am really open and looking for those things to be implemented, but without using any third party tools or at least without paying for any license.
Thank you my friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
|
Two options are described here Working with multiple Web.Config files | Dean Hume[^]. Personally I would use the first option as it's far easier. It's also the same mechanism I use.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
I have fields on a form that have required validation. I want to have that validation when clicking on one of the links in the image. How do I do that. Here is the code for the image.
asp:Image ID="Image1" runat="server" class="image-center" src="images/CustomerSelection.png" alt="" usemap="#Map" />
<map id="Map1" name='Map'>
<area shape='rect' coords='0,0,100,100' title='Customer Selection' href="CustomerInfo.aspx" alt="Customer Selection" />
<area shape='rect' coords='148,-2,248,98' title='Contract Information' href="ContractInfo.aspx" alt="Contract Information" />
<area shape='rect' coords='275,-4,375,96' title='Prime Contractor' href='PrimeContractorUserControl.aspx' alt="Prime Contractor" />
</map>
Here are the fields that are being validated on button click:
<div class="row" style="margin-left:250px; margin-right:250px;">
<div class="col-md-6 col-md-offset-3 col-sm-6 col-sm-offset-3">
<form method="POST" action="" class="form-horizontal" id="customer-form">
<div class="form-group">
<label for="exampleInputServiceAgency">Service/Agency:</label>
<asp:DropDownList ID="custsrccode" class="form-control" name="custsrccode" runat="server">
<asp:ListItem ></asp:ListItem>
<asp:ListItem >C812 - NASA</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="fieldReqValidator1" ForeColor="Red" runat="server" ControlToValidate ="custsrccode" ErrorMessage="Please select a Service/Agency">
</asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="exampleInputCustomerCode">Buying Activity Code:</label>
<asp:DropDownList ID="activitycode" class="form-control" name="activitycode"
runat="server" AutoPostBack="true" onselectedindexchanged="activitycode_SelectedIndexChanged">
<asp:ListItem Selected="True"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="fieldReqValidator2" runat="server" ControlToValidate ="activitycode" ErrorMessage="Please select a Buying Activity Code">
</asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="exampleInputName">Name:</label>
<asp:TextBox ID="custname" class="form-control" name="custname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="fieldReqValidator3" ForeColor="Red" runat="server" ControlToValidate ="custname" ErrorMessage="Please enter a Name">
</asp:RequiredFieldValidator>
</div>
</form>
</div>
</div>
<div class="row button_margin">
<div class="col-md-1 col-sm-1 col-sm-offset-2"><button type="button" class="btn btn-primary" style="position:relative; left:130px; border-radius:2px; border:none; background-color:#003366; color:#f7f7f7">Exit</button></div>
<div class="col-md-1 col-md-offset-6 col-sm-1 col-sm-offset-6">
<asp:Label ID="Message"
runat="Server" />
<asp:Button ID="NextButton" Text="Next" type="button" class="btn btn-primary"
runat="server" style="position:relative; right:63px; border-radius:2px; border:none; background-color:#003366; color:#f7f7f7" onclick="NextButton_Click"/></div>
<input type="hidden" id="hidurl" runat="server" />
</div>
</div>
</div>
</form>
</body>
</html>
So when I click on Contract Information and the required fields on Customer Selection haven't been filled in it should give a validator message and currently it doesn't.
|
|
|
|
|
Hi All,
I have a following jQuery function, I want this function to be added to a button that is being added along with the Divs, one after the other. I have the Div adding function also, I want to assign "onRemoveClick" function to each input button that is added along with the Divs
var onRemoveClick=function () {
alert($(this).parent().attr('id'));
$(this).parent().remove();
};
Here is my Divs adding function:
var addNewDate = function ($wrapper) {
count++;
var tmpHTML = '<div class="parameterFieldResize parameterField" style="width: fit-content;" id="' + paramName + '_1_Div' + count + '">' +
'<input class="parameterDateRangePicker clearable start" style="width:70px" placeholder="Start" type="text" name="' + paramName + '_1_StartDate' + count + '" id="' + paramName + '_1_Start' + count + '" />' +
'<input class="parameterDateRangePicker clearable end" style="width:70px" placeholder="End" type="text" name="' + paramName + '_1_EndDate' + count + '" id="' + paramName + '_1_End' + count + '" />' +
'<button type="button" style="height:5px; width:5px" id="' + paramName + '_1_Remove' + count + '" class="remove-field">x</button>' +
'</div>';
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
});
$newField.find('.remove-field').on({
onClick: onRemoveClick
});
};
I am trying as in the following way, but its not working, can you please suggest me something
$newField.find('.remove-field').on({
onClick: onRemoveClick
});
any sort of help a code snippet, a link or even suggestion would be very helpful, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hi,
I am putting this here maybe somebody can use my code,
Here is how I resolved it:
$newField.find('.remove-field').on({
click: onRemoveClick
});
Happy coding guys
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
I have two dropdownlists how to bind those from mysql using jquery,C#
|
|
|
|
|
|
Hi All,
I have .js file in which I am adding some new items to the page by using the jQuery code, the Logic is once the dates are selected then it adds up an another set of the Start and End Dates. When the first set of the Input elements are firing properly and opening the Date Picker calendar the remaining added elements that are added by jQuery code at runtime not adding the Date Picker input elements.
Please anybody help me in this regards. Here is my code.
First time added like here:
template =
'<div id="Param_' + Id + '">' +
'<div class="parameterHeader ui-widget-header ui-corner-top">' + paramDisplayName + '</div>' +
'<div class="parameterItem ui-widget-content ui-corner-bottom" >' +
'<div class="parameterFieldResize parameterField" id="' + paramName + '_1_Div' + count + '">' +
'<input class="parameterDateRangePicker clearable start" placeholder="Start" type="text" name="' + paramName + '_1_StartDate' + count + '" id="' + paramName + '_1_Start' + count + '" />' +
'<input class="parameterDateRangePicker clearable end" placeholder="End" type="text" name="' + paramName + '_1_EndDate' + count + '" id="' + paramName + '_1_End' + count + '" />' +
'<button type="button" id="' + paramName + '_1_Remove' +count + '" class="remove-field">X</button>' +
'</div>' +
'</div>' +<br />
'</div>';
this.JQElem = $(template);
initialParent.append(this.JQElem);
var fullDateString = '';
$('.parameterDateRangePicker.clearable.start').datepicker({
changeMonth: true,
changeYear: true,
onSelect: function (dateText) {
$(this).trigger("input");
if (typeof me.values[this.id.split('')[1]] === 'undefined')
me.values[this.id.split('')[1]] = {};
me.values[this.id.split('_')[1]]['Start'] = dateText;
fullDateString = $(this).val() + "-" + $(this).next().val
if (fullDateString.length == 21) {
var str = fullDateString.replace(/[_\W]+/g, "");
count++;
var $wrapper = $(this).parent().parent();
var tmpHTML = '<div class="parameterFieldResize parameterField" id="' + paramName + '_1_Div' + count + '">' +
'<input class="parameterDateRangePicker clearable start" placeholder="Start" type="text" name="' + paramName + '_1_StartDate' + count + '" id="' + paramName + '_1_Start' + count + '" />' +
'<input class="parameterDateRangePicker clearable end" placeholder="End" type="text" name="' + paramName + '_1_EndDate' + count + '" id="' + paramName + '_1_End' + count + '" />' +
'<button type="button" id="' + paramName + '_1_Remove' + count + '" class="remove-field">X</button>' +
'</div>';
$wrapper.append(tmpHTML);
};<br />
}
});
$('.parameterDateRangePicker.clearable.end').datepicker({
changeMonth: true,
changeYear: true,
onSelect: function (dateText) {<br />
$(this).trigger("input");
if (typeof me.values[this.id.split('')[1]] === 'undefined')
me.values[this.id.split('')[1]] = {};
me.values[this.id.split('_')[1]]['End'] = dateText;
fullDateString = $(this).prev().val() + "-" + $(this).val();
if (fullDateString.length == 21) {
var $wrapper = $(this).parent().parent();
count++;
var tmpHTML = '<div class="parameterFieldResize parameterField" id="' + paramName + '_1_Div' + count + '">' +
'<input class="parameterDateRangePicker clearable start" placeholder="Start" type="text" name="' + paramName + '_1_StartDate' + count + '" id="' + paramName + '_1_Start' + count + '" />' +
'<input class="parameterDateRangePicker clearable end" placeholder="End" type="text" name="' + paramName + '_1_EndDate' + count + '" id="' + paramName + '_1_End' + count + '" />' +
'<button type="button" id="' + paramName + '_1_Remove' +count + '" class="remove-field">X</button>' +
'</div>';
$wrapper.append(tmpHTML);
};
}
});
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
When you call $('.parameterDateRangePicker.clearable.start').datepicker({... , that sets up the date picker for any matching elements which are already on the page.
It doesn't magically apply to elements that you add to the page at some later point. For that, you will need to call the datepicker function manually after you've added the new element.
this.JQElem = $(template).appendTo(initialParent);
this.JQElem.find('.parameterDateRangePicker.clearable.start').datepicker({...});
this.JQElem.find('.parameterDateRangePicker.clearable.end').datepicker({...});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
But in my code I am adding the datepicker code within inside the datepicker because I am adding the elements after date has been picked, I am not understanding how to add another datepicker code there? Can you please suggest me something or if you can just give me some hint here how I can add - it would be helpful buddy.
Yes unfortunately I am not that good at jQuery, can you please guide me a little bit?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
As I said in my previous response, if you add new elements to the page after you've applied the datepicker to the existing elements, then you need to manually apply the datepicker to the new elements.
I even gave you an example of the code to do that - you just need to replace the ... with the relevant options for the datepicker function.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wow its going to be fancy big function , that's what my worry was worried about- welcome to the world of client scripting . Personally I like to do Application to Application Integration. But unfortunately I have to do this every once in a while to fill my and my family's belly.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
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
|
|
|
|
|
|
|