Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all 3509 articles
Browse latest View live

get a menu on link button hover

$
0
0

hello,

I wanna get a menu when my mouse is over a link button so I wrote:

<td style="padding-right:50px;vertical-align:top"><div id="div2"><asp:LinkButton ID="LinkButton7" runat="server" ToolTip="View girls clothes" onclick="GirlsButton_Click">Girls</asp:LinkButton>                               <div id="div1" style="height:auto; margin-top:5%;width:auto;  "><div><asp:Menu ID="Menu1" runat="server" onmenuitemclick="Menu1_MenuItemClick">  </asp:Menu></div></div></div></td>

and in the css I placed:

 div#div1
 {     
   display:none;
 }

 
div#div2:hover #div1
 {
    
     display:table-row;
 }
 
 

So I am getting what I want when my mouse is over the button I am getting the menu, but the problem is that the td of the table changes depending on the words in the menu and I need my td width to be stable so how can I do this?

I tried to add a  certain width for the td but that didn't work and I tried to add:

td
{
word-break:break-all;
}

but that didn't work either so what to do? please help!!


Entity framework Update wizard VS 2013: cannot select Table checkbox (unresponsive)

$
0
0

I am using Entity framework UpdateWizard in VS 2013, to update model from database, but I'm unable to select the tables checkbox. It has become unresponsive. It was working fine sometime back.  No idea how to fix it. I tried restarting VS,  rebuild the solution , but it did not work. Any suggestions?

Thanks,

Rose 

Visual Web Developer 2012 Express save new web site file name

$
0
0

I an trying to learn Visual Web Developer 2012 Express and have created a simple site with two empty pages. I can't find a way to save the site folder with its several files.

value does not fall within the expected range

$
0
0

getting error while opening visual studio 2013 

How do I extract values from a gridview row and pass to another form?

$
0
0

I have a dropdownlist where the user selects a part number which is in turn placed into a gridview table along with the part type.  When the user has selected the correct part number he/she can then click on a button to send this part to the appropriate form for editing.  My routine is below but I have not been able to get it to work.  It appears nothing is getting selected to pass to the next form.  The first cell in gridview is the part number, the second is the part type which should determine which form the part number is sent to.

    Protected Sub Button4_Click(sender As Object, e As System.EventArgs) Handles Button4.Click  'Go To Part
        '0 = PART_NUMBER
        '1 = CompType
        For Each x As GridViewRow In GridView1.Rows
            If x.RowType = DataControlRowType.DataRow Then
                PtNo = x.Cells(0).Text
                Typ = x.Cells(1).Text
            End If
        Next
        If Typ = "Capacitors" Then Response.Redirect("Capacitors1.aspx?Data=" & PtNo)
        If Typ = "Connectors" Then Response.Redirect("Connectors1.aspx?Data=" & PtNo)
        If Typ = "Crystals and Oscillators" Then Response.Redirect("Crystals1.aspx?Data=" & PtNo)
        If Typ = "Diodes" Then Response.Redirect("Diodes1.aspx?Data=" & PtNo)
        If Typ = "ICs" Then Response.Redirect("ICs1.aspx?Data=" & PtNo)
        If Typ = "Inductors" Then Response.Redirect("Inductors1.aspx?Data=" & PtNo)
        If Typ = "Misc" Then Response.Redirect("Misc1.aspx?Data=" & PtNo)
        If Typ = "Relays" Then Response.Redirect("Relays1.aspx?Data=" & PtNo)
        If Typ = "Resistors" Then Response.Redirect("Resistors1.aspx?Data=" & PtNo)
        If Typ = "Switches" Then Response.Redirect("Switches1.aspx?Data=" & PtNo)
        If Typ = "Transformers" Then Response.Redirect("Transformers1.aspx?Data=" & PtNo)
        If Typ = "Transistors" Then Response.Redirect("Transistors1.aspx?Data=" & PtNo)
    End Sub

Does anyone have any suggestions as to what I'm doing wrong?

Thanks

issues for NuGet after migrating a c# project

$
0
0

Hi,

i'm trying to migrate a progect into my visual studio 2012.

On the Manage NuGet Packages, I have this issue:

"Some NuGet Packages are missing from this solution. Click to restore from your online package sources"... but when i click on the restore button, it appears this issue:

 "an error occurred while trying to restore packages: Unable to find version '4.1.0-alpha-121112' of package 'Microsoft.AspNet.WebApi'. "

i'm using .NET Framework 4

How can i solve?

Thanks in advance....

WOW - error after update to VS 2013.3

$
0
0

I just updated VS 2013 Pro to 2013.3.

Now when I run a website on localhost, I get the error:

Line: 65
Error: Object doesn't support property or method 'bind'

What's going on?  This did not happen before the update.  I look at line 65 and it is a giant generated javascript:

try { this.addExtension("Microsoft.VisualStudio.Web.BrowserLink.HtmlMappingExtensionFactory", (function(n,t){function k(){var b=this,w=function(n,i){var e,r,u,o;if(!i)return null;if(e=f(i),e)return e.selectorData==n?e:null;if(t(i).is(n.selector)){if(r=null,n.parent){for(u=i.parentElement,o=n.selector.split(">").length-1;o>0;o--)u=u.parentElement;s(n.parent,u)&&(r=t(i.parentElement).children(n.selector))}else n.descendant?t(i).find(n.descendant.selectorData.selector).each(function(i,u){if(s(n.descendant,u))return r=t(u).parents(n.selector),!1}):r=t(n.selector);r&&v(n,r)&&(r.each(function(t,i){if(!p(i)){var u=t%n.elements.length,r=n.elements[u];r&&a(i,r)}}),n.isInTemplateLike||d(n))}return f(i)},s=function(n,t){return w(n.selectorData,t)==n},nt=function(n){for(var u,r,t=0;t<i.length;t++)if(u=i[t],u&&(r=w(i[t],n),r))return r;return null},e=function(n){var t=f(n);return t?t:nt(n)},l=function(n,t,i){if(n<r.length){var u=r[n];if(u)return{sourcePath:u,startPosition:t,length:i}}return null},y=function(t,i){t&&(i==null&&(i=!0),n.invoke("selectRange",t.sourcePath,t.startPosition,t.length,i))},tt=function(n,t,i){return n.sourcePath.toLowerCase()!=t.toLowerCase()?!1:n.startPosition>i?!1:i-n.startPosition>n.length?!1:!0},g=function(n,t,i){var r=n.start,f=n.length,o=r+f,e=n.startTag||0,s=r+e,u=t-i;r>=t?u>=o?(r=t,f=0,e=0):u>r?(f=o-u,r=t,e=u>=s?0:s-u):r+=i:s>t?(u>s?e=t-r:e+=i,u>o?f=t-r:f+=i):o>t&&(u>o?f=t-r:f+=i),n.start=r,n.length=f,n.startTag&&(n.startTag=e)},k=function(n,t){for(var f,e,i,r;t.length>=2;)for(f=t.shift(),e=t.shift(),i=0;i<u.length;i++)r=u[i],r.sourceIndex==n&&g(r,f,e)},c=function(t,i){if(t<r.length){var u=r[t];n.invokeAsync("getChangesInFile",u).continueWith(function(n){k(t,n),c(t+1,i)})}else i()};this.getCompleteRange=function(n){var t=e(n);return t?l(t.sourceIndex,t.start,t.length):null},this.getStartTagRange=function(n){var t=e(n);return t&&t.startTag?l(t.sourceIndex,t.start,t.startTag):null},this.selectCompleteRange=function(n){y(b.getCompleteRange(n))},this.selectStartTagRange=function(n){y(b.getStartTagRange(n))},this.canMapToSource=function(n){return e(n)!=null},this.ensureUpToDateAsync=function(n){n&&h.push(n),o||(o=!0,c(0,function(){var t=h,n;for(h=[],o=!1,n=0;n<t.length;n++)try{t[n]()}catch(i){}}))},this.getElementAtPosition=function(n,i){for(var f=null,o=null,r,e=0;e<u.length;e++)r=u[e],r.start<=i&&r.length>=i-r.start&&(f==null||f.length>r.length)&&(f=r);return f&&t(f.selectorData.selector).each(function(n,t){if(s(f,t))return o=t,!1}),o}}var l=!1,r=[],o=!0,h=[],u=[],i=[],f=function(n){return n?n.__browserLink_sourceMapping||null:null},p=function(n){return f(n)!=null},a=function(n,t){n&&(n.__browserLink_sourceMapping=t)},v=function(n,t){return n.isTemplateLike||n.isParentTemplateLike?t.length%n.elements.length==0:t.length==n.elements.length},c=function(n){var r,o,e,t,f,h,u,s;for(i.push(n),r=i.length-1;r<i.length;r++)for(o=i[r],e=0;e<o.elements.length;e++)if(t=o.elements[e],t){for(f=0;f<t.children.length;f++)h=t.children[f],i.push(h);for(u=0;u<t.ancestors.length;u++)s=t.ancestors[u],i.push(s)}},d=function(n){for(var t=0;t<i.length;t++)i[t]==n&&(i[t]=null)},nt=function(n){return t(n)},g=function(n,i){for(var u=t(n),f=i.split(">"),r=0;r<f.length;r++)u=u.children(f[r]);return u},b=function(n,i){return t(n).parents(i)},y=function(n,t){var i=t(n.selector);v(n,i)?(i.each(function(t,i){var o=t%n.elements.length,r=n.elements[o],u,f;r!=null&&(a(i,r),u=r.children,e(u,0,u.length,null,g.bind(null,i)),f=r.ancestors,e(f,0,f.length,null,b.bind(null,i)))}),n.isTemplateLike&&c(n)):c(n)},e=function(n,t,i,r,u){for(var f=t;f<t+i;f++){if(f>=n.length){r&&r();return}y(n[f],u)}t+i<n.length&&setTimeout(function(){e(n,t+i,i,r,u)},5)},w=function(n,t){e(n,0,10,t,nt)},s=function(n){var v=[],l,o,i,a,e,t,f,h,r,c;if(n)for(l=0;l<n.length;l++)for(o=n[l],i={selector:o[0],elements:[],isTemplateLike:!1},v.push(i),a=1;a<o.length;a++){if(e=o[a],t=null,e){for(f=e[0],h=e.length>=2?e[1]:{},t={selectorData:i,sourceIndex:f[0],start:f[1],length:f[2],startTag:f.length>=4?f[3]:null,children:s(h.children),ancestors:s(h.ancestors)},h.templateLike&&o.length==2&&(i.isTemplateLike=!0,i.isInTemplateLike=!0),r=0;r<t.children.length;r++)t.children[r].parent=t,t.children[r].isParentTemplateLike=i.isTemplateLike,t.children[r].isInTemplateLike=i.isInTemplateLike;for(c=0;c<t.ancestors.length;c++)t.ancestors[c].descendant=t;u.push(t)}i.elements.push(t)}return v};return n.addSharedService("sourceMapping",new k),{onConnected:function(){if(!l&&n.initializationData&&n.initializationData.requestId){var i="~/__browserLink/requestData/"+n.initializationData.requestId;n.invokeAsync("resolveUrl",i).continueWith(function(i){i&&t.ajax(i,{dataType:"json",data:{version:2},cache:!0,success:function(t){l=!0;var i=s(t.map);w(i,function(){n.invokeAsync("resolveSourceFilePaths",t.files).continueWith(function(t){r=t,o=!1,n.sourceMapping.ensureUpToDateAsync(null)})})}})})}}}})); } catch(e) { this.log("Invalid extension script encountered for extension 'Microsoft.VisualStudio.Web.BrowserLink.HtmlMappingExtensionFactory'."); return; }

Help most appreciated.

Problems with Gridview correctly obtaining data, The ntext data type cannot be selected as DISTINCT because it is not comparable.

$
0
0

I'm having problems with Gridview correctly displaying data.  First I have a drop down list that lists all part numbers from a series of tables:

        SelectCommand="SELECT PART_NUMBER FROM Capacitors UNION SELECT PART_NUMBER FROM Connectors UNION SELECT PART_NUMBER FROM [Crystals and Oscillators] UNION SELECT PART_NUMBER FROM Diodes UNION SELECT PART_NUMBER FROM ICs UNION SELECT PART_NUMBER FROM Inductors UNION SELECT PART_NUMBER FROM Misc UNION SELECT PART_NUMBER FROM Relays UNION SELECT PART_NUMBER FROM Resistors UNION SELECT PART_NUMBER FROM Switches UNION SELECT PART_NUMBER FROM Transformers UNION SELECT PART_NUMBER FROM Transistors ORDER BY PART_NUMBER">

The drop down list works fine.  Next I have a Gridview table that should extract the part number and description fields from various tables using the part number selected in the  drop down list:

        SelectCommand="SELECT [PART_NUMBER], [Description] FROM [Capacitors] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Connectors] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Crystals and Oscillators] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Diodes] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [ICs] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Inductors] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Misc] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Relays] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Resistors] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Switches] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Transformers] WHERE ([PART_NUMBER] = @PART_NUMBER) 
UNION 
SELECT [PART_NUMBER], [Description] FROM [Transistors] WHERE ([PART_NUMBER] = @PART_NUMBER)">

When the program runs I get "The ntext data type cannot be selected as DISTINCT because it is not comparable."  I simply don't understand where this error is coming from.  If I strip it down to looking at one table the problem goes away.  This should be extracting the Description field, not comparing it to anything.  Other than the addition of Description this is the same as the select command in the drop down list.  I'm completely lost on this one.

The asp section is below:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="PART_NUMBER" DataSourceID="SqlDataSource2"><Columns><asp:BoundField DataField="PART_NUMBER" HeaderText="PART_NUMBER" 
                ReadOnly="True" SortExpression="PART_NUMBER" /><asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" /></Columns></asp:GridView>

Thanks!


Website works on developers computer but not mine?

$
0
0

I have outsourced a small task to a developer. The task was to

  • Amend an existing form to allow the user to upload an image to a directory
  • Record the FULL path in the database
  • Ability to edit the record and upload a new image.

When I tried inserting a new record it would'nt upload the image. It did add the filename to the database (although it is meant to insert the entire full root path to the database). 

It would work perfectly when I edited a record (i.e. upload the image and put the full path into the database).

He tested it on multiple computers and I have tested it on multiple computers. I have tested it on multiple versions of Visual Studio. He has uploaded it to a live server and I have tested it on the live server and I can see that it works. Neither one of use are getting errors. It is just not working on my computers.

I am very new to Visual Studio and ASP.NET. Am I missing something? Is there a reason why it would work for perfectly for him and not me?

Maybe a setting or something?

Lee

Just in case you are interested in the code

InsertControl.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control-Hardware-Insert.ascx.cs" Inherits="WebUserControl" %><asp:SqlDataSource ID="SqlDataSource1" runat="server" OnSelecting="SqlDataSource1_Selecting" OnUpdating="SqlDataSource1_Updating"
    ConnectionString="<%$ ConnectionStrings:ConnectionStringGeoQ %>" 
    DeleteCommand="DELETE FROM [Hardware] WHERE [HardwareID] = @HardwareID" 
    InsertCommand="INSERT INTO [Hardware] ([HardwareName], [NSN], [AssetNo], [SerialNo], [ModelNo], [LastStockCheck], [StockCheckFreqDays], [DisposedOfDate], [DisposedBy], [WarrantyExpDate], [SustainedBy], [OwnedBy], [IsVirtualMachine], [NonTechFreqDays], [LastNonTechDate], [NonTechInstructions], [SignedOutBy], [Location], [LoanedTo], [LoanedToLocation], [ExpectedLoanReturnDate], [ServiceabilityID], [KitID], [DateAdded], [ImagePath]) VALUES (@HardwareName, @NSN, @AssetNo, @SerialNo, @ModelNo, @LastStockCheck, @StockCheckFreqDays, @DisposedOfDate, @DisposedBy, @WarrantyExpDate, @SustainedBy, @OwnedBy, @IsVirtualMachine, @NonTechFreqDays, @LastNonTechDate, @NonTechInstructions, @SignedOutBy, @Location, @LoanedTo, @LoanedToLocation, @ExpectedLoanReturnDate, @ServiceabilityID, @KitID, @DateAdded, @ImagePath)" 
    SelectCommand="SELECT * FROM [Hardware]" 
    UpdateCommand="UPDATE [Hardware] SET [ImagePath] = @ImagePath WHERE [HardwareID] = @HardwareID"><DeleteParameters><asp:Parameter Name="HardwareID" Type="Int32" /></DeleteParameters><InsertParameters><asp:Parameter Name="HardwareName" Type="String" /><asp:Parameter Name="NSN" Type="String" /><asp:Parameter Name="AssetNo" Type="String" /><asp:Parameter Name="SerialNo" Type="String" /><asp:Parameter Name="ModelNo" Type="String" /><asp:Parameter DbType="Date" Name="LastStockCheck" /><asp:Parameter Name="StockCheckFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="DisposedOfDate" /><asp:Parameter Name="DisposedBy" Type="Int32" /><asp:Parameter DbType="Date" Name="WarrantyExpDate" /><asp:Parameter Name="SustainedBy" Type="Int32" /><asp:Parameter Name="OwnedBy" Type="Int32" /><asp:Parameter Name="IsVirtualMachine" Type="Boolean" /><asp:Parameter Name="NonTechFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="LastNonTechDate" /><asp:Parameter Name="NonTechInstructions" Type="String" /><asp:Parameter Name="SignedOutBy" Type="Int32" /><asp:Parameter Name="Location" Type="String" /><asp:Parameter Name="LoanedTo" Type="Int32" /><asp:Parameter Name="LoanedToLocation" Type="String" /><asp:Parameter DbType="Date" Name="ExpectedLoanReturnDate" /><asp:Parameter Name="ServiceabilityID" Type="Int32" /><asp:Parameter Name="KitID" Type="Int32" /><asp:Parameter DbType="Date" Name="DateAdded" /><asp:Parameter Name="ImagePath" Type="String" /></InsertParameters><UpdateParameters><asp:Parameter Name="HardwareName" Type="String" /><asp:Parameter Name="NSN" Type="String" /><asp:Parameter Name="AssetNo" Type="String" /><asp:Parameter Name="SerialNo" Type="String" /><asp:Parameter Name="ModelNo" Type="String" /><asp:Parameter DbType="Date" Name="LastStockCheck" /><asp:Parameter Name="StockCheckFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="DisposedOfDate" /><asp:Parameter Name="DisposedBy" Type="Int32" /><asp:Parameter DbType="Date" Name="WarrantyExpDate" /><asp:Parameter Name="SustainedBy" Type="Int32" /><asp:Parameter Name="OwnedBy" Type="Int32" /><asp:Parameter Name="IsVirtualMachine" Type="Boolean" /><asp:Parameter Name="NonTechFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="LastNonTechDate" /><asp:Parameter Name="NonTechInstructions" Type="String" /><asp:Parameter Name="SignedOutBy" Type="Int32" /><asp:Parameter Name="Location" Type="String" /><asp:Parameter Name="LoanedTo" Type="Int32" /><asp:Parameter Name="LoanedToLocation" Type="String" /><asp:Parameter DbType="Date" Name="ExpectedLoanReturnDate" /><asp:Parameter Name="ServiceabilityID" Type="Int32" /><asp:Parameter Name="KitID" Type="Int32" /><asp:Parameter DbType="Date" Name="DateAdded" /><asp:Parameter Name="ImagePath" Type="String" /><asp:Parameter Name="HardwareID" Type="Int32" /></UpdateParameters></asp:SqlDataSource><asp:ListView ID="ListView1" runat="server" DataKeyNames="HardwareID" 
    DataSourceID="SqlDataSource1" InsertItemPosition="LastItem"><InsertItemTemplate><div style="float:none; display:block" class="span6"><div class="nopad"><table id="HardwareItem" class="table table-bordered span12" style="border-right:solid thin #C4C4C4; margin-bottom:20px;"><thead><tr><th colspan="2" class="span6">Details</th></tr></thead><tbody><tr><td>Hardware Name:</td><td><asp:TextBox ID="HWNameTextBox" runat="server" maxlength="100" 
                                Text='<%# Bind("HardwareName") %>' />                          </td></tr><tr><td>NSN:</td><td><asp:TextBox ID="NSNTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("NSN") %>' />                           </td></tr><tr><td>Asset No:</td><td><asp:TextBox ID="AssetNoTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("AssetNo") %>' />                           </td></tr><tr><td>Serial No:</td><td><asp:TextBox ID="SerialNoTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("SerialNo") %>' />                           </td></tr><tr><td>Model No:</td><td><asp:TextBox ID="ModelNoTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("ModelNo") %>' />                           </td></tr><tr><td>Is This a Virtual Machine:</td><td><asp:CheckBox ID="IsVirtualMachineCheckBox" runat="server" Checked='<%# Bind("IsVirtualMachine") %>' /></td></tr><tr><td>Serviceability:</td><td>               <asp:DropDownList ID="DropDownListServiceability" runat="server" 
                                    OnDataBound="AddNullValueToDropDownList_DataBound" AppendDataBoundItems="true" 
                                    DataSourceID="ServiceabilityList" DataTextField="ServiceabilityName" DataValueField="ServiceabilityID"  
                                    SelectedValue='<%# Bind("ServiceabilityID") %>'><asp:listitem value="" text="Select a value"></asp:listitem></asp:DropDownList><asp:SqlDataSource ID="ServiceabilityList" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ConnectionStringGeoQ %>" 
                                    SelectCommand="SELECT * FROM [Serviceability]"></asp:SqlDataSource>                        </td></tr><tr><td>Kit Name:</td><td><asp:DropDownList ID="DropDownList_Kit" runat="server" 
                                    OnDataBound="AddNullValueToDropDownList_DataBound" AppendDataBoundItems="true" 
                                    DataSourceID="KitList" DataTextField="KitName" DataValueField="KitID"  
                                    SelectedValue='<%# Bind("KitID") %>'><asp:listitem value="" text="Select a value"></asp:listitem></asp:DropDownList><asp:SqlDataSource ID="KitList" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ConnectionStringGeoQ %>" 
                                    SelectCommand="SELECT * FROM [Kit]"></asp:SqlDataSource>  </td></tr><tr><td>Image:</td><td><asp:FileUpload ID="ImageFileUpload" AllowMultiple="false" ClientIDMode="Static" runat="server" /><asp:HiddenField ID="ImagePathHdn" ClientIDMode="Static" runat="server" Value='<%# Bind("ImagePath") %>' /> <asp:HiddenField ID="OldHardwareId" ClientIDMode="Static" runat="server" /> <asp:HiddenField ID="ImageFolderPath" ClientIDMode="Static" Value='<%# ResolveUrl("~" + ConfigurationManager.AppSettings["ImagePath"]) %>' runat="server" /> <div id="uploadPreview"></div></td></tr></tbody></table></div><div class="nopad"><table id="Governance" class="table table-bordered span12" style="border-right:solid thin #C4C4C4; margin-bottom:20px;"><thead><tr><th colspan="2" class="span6">Governance</th></tr></thead><tbody><tr><td class="span6">Last Stock Check Date:</td><td class="span6"><asp:TextBox ID="LastStockCheck_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("LastStockCheck", "{0:dd MMM yyyy}") %>' />                           </td></tr><tr><td>Stock Check Frequency (Days):</td><td><asp:TextBox ID="StockCheckFreqDaysTextBox" runat="server" 
                                Text='<%# Bind("StockCheckFreqDays") %>' />                           </td></tr><tr><td>Disposed Of Date:</td><td><asp:TextBox ID="DisposedOfDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("DisposedOfDate", "{0:dd MMM yyyy}") %>' />                        </td></tr><tr><td>Disposed By:</td><td><asp:TextBox ID="DisposedByTextBox" runat="server" 
                                Text='<%# Bind("DisposedBy") %>' />                           </td></tr><tr><td>Warranty Expiry Date:</td><td><asp:TextBox ID="WarrantyExpDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("WarrantyExpDate", "{0:dd MMM yyyy}") %>' />                           </td></tr><tr><td>Non-Tech Frequency (Days):</td><td><asp:TextBox ID="NonTechFreqDaysTextBox" runat="server" 
                                Text='<%# Bind("NonTechFreqDays") %>' />                           </td></tr><tr><td>Last Non-Tech Date:</td><td><asp:TextBox ID="LastNonTechDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("LastNonTechDate", "{0:dd MMM yyyy}") %>' />                           </td></tr><tr><td>Non-Tech Instructions:</td><td><asp:TextBox ID="NonTechInstructionstextarea" runat="server" 
                                    TextMode="MultiLine" Text='<%# Bind("NonTechInstructions") %>'></asp:TextBox></td></tr></tbody></table></div><div class="nopad"><table id="Ownership" class="table table-bordered span12" style="border-right:solid thin #C4C4C4; margin-bottom:20px;"><thead><tr><th colspan="2" class="span6">Ownership</th></tr></thead><tbody><tr><td class="span6">Sustained By:</td><td class="span6"><asp:TextBox ID="SustainedByTextBox" runat="server" 
                                Text='<%# Bind("SustainedBy") %>' />                           </td></tr><tr><td>Owned By:</td><td><asp:TextBox ID="OwnedByTextBox" runat="server" 
                                Text='<%# Bind("OwnedBy") %>' />                           </td></tr><tr><td>Signed Out By:</td><td><asp:TextBox ID="SignedOutByTextBox" runat="server" 
                                Text='<%# Bind("SignedOutBy") %>' />                           </td></tr><tr><td>Location:</td><td><asp:TextBox ID="LocationTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("Location") %>' />                           </td></tr><tr><td>Loaned To:</td><td><asp:TextBox ID="LoanedToTextBox" runat="server" 
                                Text='<%# Bind("LoanedTo") %>' />                           </td></tr><tr><td>Loaned To Location:</td><td><asp:TextBox ID="LoanedToLocationTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("LoanedToLocation") %>' />                           </td></tr><tr><td>Expected Loan Return Date:</td><td><asp:TextBox ID="ExpectedLoanReturnDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("ExpectedLoanReturnDate", "{0:dd MMM yyyy}") %>' />                           </td></tr></tbody></table></div><div><asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" CssClass="btn marginR10 marginB10"  
                        Text="Insert" /></div><br /><br /><br /><br /></div></InsertItemTemplate><ItemTemplate></ItemTemplate><AlternatingItemTemplate></AlternatingItemTemplate><EditItemTemplate></EditItemTemplate><EmptyDataTemplate><span>No data was returned.</span></EmptyDataTemplate><LayoutTemplate><div ID="itemPlaceholderContainer" runat="server" style=""><span runat="server" id="itemPlaceholder" /></div><div style=""></div></LayoutTemplate><SelectedItemTemplate></SelectedItemTemplate></asp:ListView>

InsertControl.ascx.cs

using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web.UI.WebControls;

public partial class WebUserControl : System.Web.UI.UserControl
{
    protected string path = ConfigurationManager.AppSettings["ImagePath"];
    protected string[] allowedExtenstions = new string[] { ".png", ".jpg", ".jpeg", ".gif" };

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void AddNullValueToDropDownList_DataBound(object sender, EventArgs e)
    {
        DropDownList dropdownlist = (DropDownList)sender;
        if (dropdownlist.SelectedValue == string.Empty)
        {
            dropdownlist.Items[0].Enabled = true;
        }
    }

    protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        
        try
        {
            var flpImage = (FileUpload)ListView1.InsertItem.FindControl("ImageFileUpload");
            var flpImageHdn = (HiddenField)ListView1.InsertItem.FindControl("ImagePathHdn");
            //var oldHardwareId = (HiddenField)ListView1.InsertItem.FindControl("OldHardwareId");


            string Connection = ConfigurationManager.ConnectionStrings["ConnectionStringGeoQ"].ConnectionString;
            SqlConnection db = new SqlConnection(Connection);
            string sql = "select top 1 HardwareID from  [GeoQ].[dbo].[Hardware] where ImagePath like '%" + flpImage.FileName + "%' order by HardwareID desc";
            int lastenteredId = 0;
            using (var command = new SqlCommand(sql, db))
            {
                db.Open();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        lastenteredId = reader.GetInt32(0);
                    }
                }

            }

            var physicalPath = Server.MapPath("~" + path);

            if (flpImage.HasFile)
            {
                var fullImagePath = physicalPath + lastenteredId + Path.GetExtension(flpImage.FileName);
                flpImage.SaveAs(fullImagePath);

                SqlDataSource1.Update();

                if (allowedExtenstions.Contains(Path.GetExtension(flpImage.FileName).ToLower()))
                {
                    CreateThumbnail(fullImagePath, Convert.ToInt32(ConfigurationManager.AppSettings["allowedWidth"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["allowedHeight"]));
                }

                
            }
            else if (!string.IsNullOrEmpty(flpImageHdn.Value))
            {
                var oldImage = Server.MapPath("~" + flpImageHdn.Value);
                var fullImagePath = physicalPath + lastenteredId + Path.GetExtension(flpImageHdn.Value);

                File.Copy(oldImage, fullImagePath);

                SqlDataSource1.Update();

                if (allowedExtenstions.Contains(Path.GetExtension(flpImageHdn.Value).ToLower()))
                {
                    CreateThumbnail(fullImagePath, Convert.ToInt32(ConfigurationManager.AppSettings["allowedWidth"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["allowedHeight"]));
                }
            }
        }
        catch (Exception ex)
        {
            //throw;
        }
    }
	protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
    {
        var flpImage = (FileUpload)ListView1.InsertItem.FindControl("ImageFileUpload");
        var flpImageHdn = (HiddenField)ListView1.InsertItem.FindControl("ImagePathHdn");

        string Connection = ConfigurationManager.ConnectionStrings["ConnectionStringGeoQ"].ConnectionString;
        SqlConnection db = new SqlConnection(Connection);
        string sql = "select top 1 HardwareID from  [GeoQ].[dbo].[Hardware] where ImagePath like '%" + flpImage.FileName + "%' order by HardwareID desc";
        int lastenteredId = 0;
        using (var command = new SqlCommand(sql, db))
        {
            db.Open();
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    lastenteredId = reader.GetInt32(0);
                }
            }

        }

        e.Command.Parameters["@HardwareID"].Value = lastenteredId;
	    if (flpImage.HasFile)
	    {
	        e.Command.Parameters["@ImagePath"].Value = path + lastenteredId + Path.GetExtension(flpImage.FileName);
	    }
	    else
	    {
            e.Command.Parameters["@ImagePath"].Value = path + lastenteredId + Path.GetExtension(flpImageHdn.Value);
	    }

    }

    public static void CreateThumbnail(string lcFilename, int lnWidth, int lnHeight)
    {

        System.Drawing.Bitmap bmpOut = null;

        try
        {
            Bitmap loBMP = new Bitmap(lcFilename);
            ImageFormat loFormat = loBMP.RawFormat;

            decimal lnRatio;
            int lnNewWidth = 0;
            int lnNewHeight = 0;

            if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
                return;

            if (loBMP.Width > loBMP.Height)
            {
                lnRatio = (decimal)lnWidth / loBMP.Width;
                lnNewWidth = lnWidth;
                decimal lnTemp = loBMP.Height * lnRatio;
                lnNewHeight = (int)lnTemp;
            }
            else
            {
                lnRatio = (decimal)lnHeight / loBMP.Height;
                lnNewHeight = lnHeight;
                decimal lnTemp = loBMP.Width * lnRatio;
                lnNewWidth = (int)lnTemp;
            }


            bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
            Graphics g = Graphics.FromImage(bmpOut);
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
            g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
            
            loBMP.Dispose();
        }
        catch
        {
            return;
        }
        bmpOut.Save(lcFilename);
    }
}

EditControl.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control-Hardware-Edit.ascx.cs" Inherits="Controls_WebUserControl" %><div><asp:SqlDataSource ID="SqlDataSourceHardware" runat="server" OnUpdating="SqlDataSourceHardware_Updating" EnableCaching="False"
            ConnectionString="<%$ ConnectionStrings:ConnectionStringGeoQ %>" 
            DeleteCommand="DELETE FROM [Hardware] WHERE [HardwareID] = @HardwareID" 
            InsertCommand="INSERT INTO [Hardware] ([HardwareName], [NSN], [AssetNo], [SerialNo], [ModelNo], [LastStockCheck], [StockCheckFreqDays], [DisposedOfDate], [DisposedBy], [WarrantyExpDate], [SustainedBy], [OwnedBy], [IsVirtualMachine], [NonTechFreqDays], [LastNonTechDate], [NonTechInstructions], [SignedOutBy], [Location], [LoanedTo], [LoanedToLocation], [ExpectedLoanReturnDate], [ServiceabilityID], [KitID], [ImagePath]) VALUES (@HardwareName, @NSN, @AssetNo, @SerialNo, @ModelNo, @LastStockCheck, @StockCheckFreqDays, @DisposedOfDate, @DisposedBy, @WarrantyExpDate, @SustainedBy, @OwnedBy, @IsVirtualMachine, @NonTechFreqDays, @LastNonTechDate, @NonTechInstructions, @SignedOutBy, @Location, @LoanedTo, @LoanedToLocation, @ExpectedLoanReturnDate, @ServiceabilityID, @KitID, @ImagePath)" 

            UpdateCommand="UPDATE [Hardware] SET [HardwareName] = @HardwareName, [NSN] = @NSN, [AssetNo] = @AssetNo, [SerialNo] = @SerialNo, [ModelNo] = @ModelNo, [LastStockCheck] = @LastStockCheck, [StockCheckFreqDays] = @StockCheckFreqDays, [DisposedOfDate] = @DisposedOfDate, [DisposedBy] = @DisposedBy, [WarrantyExpDate] = @WarrantyExpDate, [SustainedBy] = @SustainedBy, [OwnedBy] = @OwnedBy, [IsVirtualMachine] = @IsVirtualMachine, [NonTechFreqDays] = @NonTechFreqDays, [LastNonTechDate] = @LastNonTechDate, [NonTechInstructions] = @NonTechInstructions, [SignedOutBy] = @SignedOutBy, [Location] = @Location, [LoanedTo] = @LoanedTo, [LoanedToLocation] = @LoanedToLocation, [ExpectedLoanReturnDate] = @ExpectedLoanReturnDate, [ImagePath] = @ImagePath, [ServiceabilityID] = @ServiceabilityID, [KitID] = @KitID WHERE [HardwareID] = @HardwareID"><DeleteParameters><asp:Parameter Name="HardwareID" Type="Int32" /></DeleteParameters><InsertParameters><asp:Parameter Name="HardwareName" Type="String" /><asp:Parameter Name="NSN" Type="String" /><asp:Parameter Name="AssetNo" Type="String" /><asp:Parameter Name="SerialNo" Type="String" /><asp:Parameter Name="ModelNo" Type="String" /><asp:Parameter Name="LastStockCheck" Type="String" /><asp:Parameter Name="StockCheckFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="DisposedOfDate" /><asp:Parameter Name="DisposedBy" Type="Int32" /><asp:Parameter DbType="Date" Name="WarrantyExpDate" /><asp:Parameter Name="SustainedBy" Type="Int32" /><asp:Parameter Name="OwnedBy" Type="Int32" /><asp:Parameter Name="IsVirtualMachine" Type="Boolean" /><asp:Parameter Name="NonTechFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="LastNonTechDate" /><asp:Parameter Name="NonTechInstructions" Type="String" /><asp:Parameter Name="SignedOutBy" Type="Int32" /><asp:Parameter Name="Location" Type="String" /><asp:Parameter Name="LoanedTo" Type="Int32" /><asp:Parameter Name="LoanedToLocation" Type="String" /><asp:Parameter DbType="Date" Name="ExpectedLoanReturnDate" /><asp:Parameter Name="ServiceabilityID" Type="Int32" /><asp:Parameter Name="KitID" Type="Int32" /><asp:Parameter Name="ImagePath" Type="String" /></InsertParameters><SelectParameters><asp:QueryStringParameter DefaultValue="1" Name="HardwareID" 
                    QueryStringField="HardwareID" /></SelectParameters><UpdateParameters><asp:Parameter Name="HardwareName" Type="String" /><asp:Parameter Name="NSN" Type="String" /><asp:Parameter Name="AssetNo" Type="String" /><asp:Parameter Name="SerialNo" Type="String" /><asp:Parameter Name="ModelNo" Type="String" /><asp:Parameter Name="LastStockCheck" Type="String" /><asp:Parameter Name="StockCheckFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="DisposedOfDate" /><asp:Parameter Name="DisposedBy" Type="Int32" /><asp:Parameter DbType="Date" Name="WarrantyExpDate" /><asp:Parameter Name="SustainedBy" Type="Int32" /><asp:Parameter Name="OwnedBy" Type="Int32" /><asp:Parameter Name="IsVirtualMachine" Type="Boolean" /><asp:Parameter Name="NonTechFreqDays" Type="Int32" /><asp:Parameter DbType="Date" Name="LastNonTechDate" /><asp:Parameter Name="NonTechInstructions" Type="String" /><asp:Parameter Name="SignedOutBy" Type="Int32" /><asp:Parameter Name="Location" Type="String" /><asp:Parameter Name="LoanedTo" Type="Int32" /><asp:Parameter Name="LoanedToLocation" Type="String" /><asp:Parameter DbType="Date" Name="ExpectedLoanReturnDate" /><asp:Parameter Name="ServiceabilityID" Type="Int32" /><asp:Parameter Name="KitID" Type="Int32" /><asp:Parameter Name="HardwareID" Type="Int32" /><asp:Parameter Name="ImagePath" Type="String" /></UpdateParameters></asp:SqlDataSource><asp:FormView ID="FormView1" runat="server" DataKeyNames="HardwareID" 
            DataSourceID="SqlDataSourceHardware" 
            EmptyDataText="No Information Available<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"><EditItemTemplate><table id="HardwareItem" class="table table-bordered span12"><thead><tr><th colspan="2" class="span12">Details</th></tr></thead><tbody><tr><td class="span6">GeoQ ID:</td><td class="span6"><asp:Label ID="HardwareIDLabel" runat="server" 
                                    Text='<%# Eval("HardwareID") %>' />                            </td></tr><tr><td>Hardware Name:</td><td><asp:TextBox ID="HardwareNameTextBox" runat="server" maxlength="100" 
                                Text='<%# Bind("HardwareName") %>' />                           </td></tr><tr><td>NSN:</td><td><asp:TextBox ID="NSNTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("NSN") %>' />                           </td></tr><tr><td>Asset No:</td><td><asp:TextBox ID="AssetNoTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("AssetNo") %>' />                           </td></tr><tr><td>Serial No:</td><td><asp:TextBox ID="SerialNoTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("SerialNo") %>' />                           </td></tr><tr><td>Model No:</td><td><asp:TextBox ID="ModelNoTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("ModelNo") %>' />                           </td></tr><tr><td>Is This a Virtual Machine:</td><td><asp:CheckBox ID="IsVirtualMachineCheckBox" runat="server" Checked='<%# Bind("IsVirtualMachine") %>' /></td></tr><tr><td>Serviceability:</td><td>               <asp:DropDownList ID="DropDownListServiceability" runat="server" 
                                    OnDataBound="AddNullValueToDropDownList_DataBound" AppendDataBoundItems="true" 
                                    DataSourceID="ServiceabilityList" DataTextField="ServiceabilityName" DataValueField="ServiceabilityID"  
                                    SelectedValue='<%# Bind("ServiceabilityID") %>'><asp:listitem value="" text="Select a value"></asp:listitem></asp:DropDownList><asp:SqlDataSource ID="ServiceabilityList" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ConnectionStringGeoQ %>" 
                                    SelectCommand="SELECT * FROM [Serviceability]"></asp:SqlDataSource>  </td></tr><tr><td>Kit Name:</td><td><asp:DropDownList ID="DropDownList_Kit" runat="server" 
                                    OnDataBound="AddNullValueToDropDownList_DataBound" AppendDataBoundItems="true" 
                                    DataSourceID="KitList" DataTextField="KitName" DataValueField="KitID"  
                                    SelectedValue='<%# Bind("KitID") %>'><asp:listitem value="" text="Select a value"></asp:listitem></asp:DropDownList><asp:SqlDataSource ID="KitList" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:ConnectionStringGeoQ %>" 
                                    SelectCommand="SELECT * FROM [Kit]"></asp:SqlDataSource>                         </td></tr><tr><td>Image:</td><td><asp:FileUpload ID="ImageFileUpload" AllowMultiple="false" ClientIDMode="Static" runat="server" /><asp:HiddenField ID="ImagePathHdn" ClientIDMode="Static" runat="server" Value='<%# Bind("ImagePath") %>' /> <asp:HiddenField ID="DBImagePath" ClientIDMode="Static" runat="server" Value='<%# Bind("fullPath") %>' /> <div id="uploadPreview"><asp:Image ID="imgPreview" CssClass="imgPreview" ClientIDMode="Static" ImageUrl='<%# Bind("fullPath")%>' runat="server" /></div></td></tr></tbody></table></div><div class="nopad"><table id="Governance" class="table table-bordered span12"><thead><tr><th colspan="2" class="span12">Governance</th></tr></thead><tbody><tr><td class="span6">Last Stock Check Date:</td><td class="span6"><asp:TextBox ID="LastStockCheck_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("LastStockCheck", "{0:dd MMM yyyy}") %>' />                           </td></tr><tr><td>Stock Check Frequency (Days):</td><td><asp:TextBox ID="StockCheckFreqDaysTextBox" runat="server" 
                                Text='<%# Bind("StockCheckFreqDays") %>' />                           </td></tr><tr><td>Disposed Of Date:</td><td><asp:TextBox ID="DisposedOfDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("DisposedOfDate", "{0:dd MMM yyyy}") %>' />                        </td></tr><tr><td>Disposed By:</td><td><asp:TextBox ID="DisposedByTextBox" runat="server" 
                                Text='<%# Bind("DisposedBy") %>' />                           </td></tr><tr><td>Warranty Expiry Date:</td><td><asp:TextBox ID="WarrantyExpDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("WarrantyExpDate", "{0:dd MMM yyyy}") %>' />                           </td></tr><tr><td>Non-Tech Frequency (Days):</td><td><asp:TextBox ID="NonTechFreqDaysTextBox" runat="server" 
                                Text='<%# Bind("NonTechFreqDays") %>' />                           </td></tr><tr><td>Last Non-Tech Date:</td><td><asp:TextBox ID="LastNonTechDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("LastNonTechDate", "{0:dd MMM yyyy}") %>' />                           </td></tr><tr><td>Non-Tech Instructions:</td><td><asp:TextBox ID="NonTechInstructionstextarea" runat="server" 
                                    TextMode="MultiLine" Text='<%# Bind("NonTechInstructions") %>'></asp:TextBox></td></tr></tbody></table></div><div class="nopad"><table id="Ownership" class="table table-bordered span12"><thead><tr><th colspan="2" class="span12">Ownership</th></tr></thead><tbody><tr><td class="span6">Sustained By:</td><td class="span6"><asp:TextBox ID="SustainedByTextBox" runat="server" 
                                Text='<%# Bind("SustainedBy") %>' />                           </td></tr><tr><td>Owned By:</td><td><asp:TextBox ID="OwnedByTextBox" runat="server" 
                                Text='<%# Bind("OwnedBy") %>' />                           </td></tr><tr><td>Signed Out By:</td><td><asp:TextBox ID="SignedOutByTextBox" runat="server" 
                                Text='<%# Bind("SignedOutBy") %>' />                           </td></tr><tr><td>Location:</td><td><asp:TextBox ID="LocationTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("Location") %>' />                           </td></tr><tr><td>Loaned To:</td><td><asp:TextBox ID="LoanedToTextBox" runat="server" 
                                Text='<%# Bind("LoanedTo") %>' />                           </td></tr><tr><td>Loaned To Location:</td><td><asp:TextBox ID="LoanedToLocationTextBox" runat="server" maxlength="50" 
                                Text='<%# Bind("LoanedToLocation") %>' />                           </td></tr><tr><td>Expected Loan Return Date:</td><td><asp:TextBox ID="ExpectedLoanReturnDate_aspnetdatepicker" runat="server" 
                                Text='<%# Bind("ExpectedLoanReturnDate", "{0:dd MMM yyyy}") %>' />                           </td></tr></tbody></table><asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CssClass="btn marginR10 marginB10" 
                        CommandName="Update" Text="Update" /><asp:LinkButton ID="UpdateCancelButton" runat="server" CssClass="btn marginR10 marginB10" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:LinkButton ID="DeleteButton_aspnetSimpleConfirmDelete" runat="server" OnClick="DeleteButton_aspnetSimpleConfirmDelete_Click" CausesValidation="False" CssClass="btn btn-danger marginR10 marginB10"  
                            OnClientClick="return confirm('Are you sure you want to delete this record?');" 
                            CommandName="Delete" Text="<span class='icomoon-icon-remove white'></span> Delete " /></EditItemTemplate><InsertItemTemplate>
                HardwareName:<asp:TextBox ID="HardwareNameTextBox" runat="server" 
                    Text='<%# Bind("HardwareName") %>' /><br />
                NSN:<asp:TextBox ID="NSNTextBox" runat="server" Text='<%# Bind("NSN") %>' /><br />
                AssetNo:<asp:TextBox ID="AssetNoTextBox" runat="server" Text='<%# Bind("AssetNo") %>' /><br />
                SerialNo:<asp:TextBox ID="SerialNoTextBox" runat="server" 
                    Text='<%# Bind("SerialNo") %>' /><br />
                ModelNo:<asp:TextBox ID="ModelNoTextBox" runat="server" Text='<%# Bind("ModelNo") %>' /><br />
                LastStockCheck:<asp:TextBox ID="LastStockCheckTextBox" runat="server" 
                    Text='<%# Bind("LastStockCheck") %>' /><br />
                StockCheckFreqDays:<asp:TextBox ID="StockCheckFreqDaysTextBox" runat="server" 
                    Text='<%# Bind("StockCheckFreqDays") %>' /><br />
                DisposedOfDate:<asp:TextBox ID="DisposedOfDateTextBox" runat="server" 
                    Text='<%# Bind("DisposedOfDate") %>' /><br />
                DisposedBy:<asp:TextBox ID="DisposedByTextBox" runat="server" 
                    Text='<%# Bind("DisposedBy") %>' /><br />
                WarrantyExpDate:<asp:TextBox ID="WarrantyExpDateTextBox" runat="server" 
                    Text='<%# Bind("WarrantyExpDate") %>' /><br />
                SustainedBy:<asp:TextBox ID="SustainedByTextBox" runat="server" 
                    Text='<%# Bind("SustainedBy") %>' /><br />
                OwnedBy:<asp:TextBox ID="OwnedByTextBox" runat="server" Text='<%# Bind("OwnedBy") %>' /><br />
                IsVirtualMachine:<asp:CheckBox ID="IsVirtualMachineCheckBox" runat="server" 
                    Checked='<%# Bind("IsVirtualMachine") %>' /><br />
                NonTechFreqDays:<asp:TextBox ID="NonTechFreqDaysTextBox" runat="server" 
                    Text='<%# Bind("NonTechFreqDays") %>' /><br />
                LastNonTechDate:<asp:TextBox ID="LastNonTechDateTextBox" runat="server" 
                    Text='<%# Bind("LastNonTechDate") %>' /><br />
                NonTechInstructions:<asp:TextBox ID="NonTechInstructionsTextBox" runat="server" 
                    Text='<%# Bind("NonTechInstructions") %>' /><br />
                SignedOutBy:<asp:TextBox ID="SignedOutByTextBox" runat="server" 
                    Text='<%# Bind("SignedOutBy") %>' /><br />
                Location:<asp:TextBox ID="LocationTextBox" runat="server" 
                    Text='<%# Bind("Location") %>' /><br />
                LoanedTo:<asp:TextBox ID="LoanedToTextBox" runat="server" 
                    Text='<%# Bind("LoanedTo") %>' /><br />
                LoanedToLocation:<asp:TextBox ID="LoanedToLocationTextBox" runat="server" 
                    Text='<%# Bind("LoanedToLocation") %>' /><br />
                ExpectedLoanReturnDate:<asp:TextBox ID="ExpectedLoanReturnDateTextBox" runat="server" 
                    Text='<%# Bind("ExpectedLoanReturnDate") %>' /><br />

                Serviceability:
                <asp:TextBox ID="ServiceabilityTextBox" runat="server" 
                    Text='<%# Bind("ServiceabilityID") %>' /><br />

                KitID:
                <asp:TextBox ID="KitIDTextBox" runat="server" Text='<%# Bind("KitID") %>' /><br />
                KitName:<asp:TextBox ID="KitNameTextBox" runat="server" Text='<%# Bind("KitName") %>' /><br /><asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" /></InsertItemTemplate><ItemTemplate><div class="nopad"><table id="HardwareItem" class="table table-bordered span12"><thead><tr><th colspan="2" class="span12">Details</th></tr></thead><tbody><tr><td class="span4">GeoQ ID:</td><td class="span8"><%# Eval("HardwareID") %></td></tr><tr><td>Hardware Name:</td><td><%# Eval("HardwareName") %></td></tr>   <tr><td>NSN:</td><td><%# Eval("NSN")%></td></tr> <tr><td>Asset No:</td><td><%# Eval("AssetNo")%></td></tr> <tr><td>Serial No:</td><td><%# Eval("SerialNo")%></td></tr> <tr><td>Model No:</td><td><%# Eval("ModelNo")%></td></tr> <tr><td>Is This a Virtual Machine:</td><td><%# Eval("IsVirtualMachine")%></td></tr> <tr><td>Servicability:</td><td><%# Eval("ServiceabilityName")%></td></tr><tr><td>Part of Kit:</td><td><%# Eval("KitName")%></td></tr><tr><td>Image:</td><td><asp:Image ID="imgPreview" class="imgPreview" ImageUrl='<%# Eval("fullPath")%>' runat="server"/></td></tr>  </tbody></table></div><div class="nopad"><table id="Governance" class="table table-bordered span12"><thead><tr><th colspan="2" class="span12">Governance</th></tr></thead><tbody><tr><td class="span4">Last Stock Check Date:</td><td class="span8"><%# Eval("LastStockCheck", "{0:dd MMM yyyy}")%></td></tr> <tr><td>Stock Check Frequency (Days):</td><td><%# Eval("StockCheckFreqDays")%></td></tr> <tr><td>Disposed Of Date:</td><td><%# Eval("DisposedOfDate", "{0:dd MMM yyyy}") %></td></tr> <tr><td>Disposed of By:</td><td><%# Eval("DisposedBy")%></td></tr> <tr><td>Warranty Expiry Date:</td><td><%# Eval("WarrantyExpDate", "{0:dd MMM yyyy}")%></td></tr> <tr><td>Non-Tech Frequency (Days):</td><td><%# Eval("NonTechFreqDays")%></td></tr>   <tr><td>Last Non-Tech Date:</td><td><%# Eval("LastNonTechDate", "{0:dd MMM yyyy}")%></td></tr><tr><td>Non-Tech Instructions:</td><td><%# Eval("NonTechInstructions")%></td></tr></tbody></table></div><div class="nopad"><table id="Ownership" class="table table-bordered span12"><thead><tr><th colspan="2" class="span12">Ownership</th></tr></thead><tbody><tr><td class="span4">Sustained By:</td><td class="span8"><%# Eval("SustainedBy")%></td></tr>    <tr><td>Owned By:</td><td><%# Eval("OwnedBy")%></td></tr>   <tr><td>Signed Out By:</td><td><%# Eval("SignedOutBy")%></td></tr><tr><td>Normal Location:</td><td><%# Eval("Location")%></td></tr><tr><td>Loaned To:</td><td><%# Eval("LoanedTo")%></td></tr><tr><td>Loaned To Location:</td><td><%# Eval("LoanedToLocation")%></td></tr><tr><td>Expected Loan Return Date:</td><td><%# Eval("ExpectedLoanReturnDate", "{0:dd MMM yyyy}")%></td></tr></tbody></table></div><asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CssClass="btn marginR10 marginB10"  
                CommandName="Edit" Text="Edit Details" />&nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CssClass="btn marginR10 marginB10" 
                CommandName="New" Text="New" /></ItemTemplate></asp:FormView><br /></div>

EditControl.ascx.cs

using System;
using System.Configuration;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web.UI.WebControls;

public partial class Controls_WebUserControl : System.Web.UI.UserControl
{
    protected string path = ConfigurationManager.AppSettings["ImagePath"];
    protected string[] allowedExtenstions = new string[] { ".png", ".jpg", ".jpeg", ".gif" };

    protected void Page_Load(object sender, EventArgs e)
    {
        string selectCommand = "SELECT Hardware.HardwareID, Hardware.HardwareName, Hardware.NSN, Hardware.AssetNo, Hardware.SerialNo, Hardware.ModelNo, Hardware.LastStockCheck, Hardware.StockCheckFreqDays, Hardware.DisposedOfDate, Hardware.DisposedBy, Hardware.WarrantyExpDate, Hardware.SustainedBy, Hardware.OwnedBy, Hardware.IsVirtualMachine, Hardware.NonTechFreqDays, Hardware.LastNonTechDate, Hardware.NonTechInstructions, Hardware.SignedOutBy, Hardware.Location, Hardware.LoanedTo, Hardware.LoanedToLocation, Hardware.ExpectedLoanReturnDate, Hardware.ImagePath, '~' + Hardware.ImagePath AS fullPath, Hardware.ServiceabilityID, Hardware.KitID, Kit.KitName, Serviceability.ServiceabilityName FROM Hardware LEFT OUTER JOIN Serviceability ON Hardware.ServiceabilityID = Serviceability.ServiceabilityID LEFT OUTER JOIN Kit ON Hardware.KitID = Kit.KitID  WHERE (Hardware.HardwareID = @HardwareID)";
        SqlDataSourceHardware.SelectCommand = selectCommand;
    }

    protected void AddNullValueToDropDownList_DataBound(object sender, EventArgs e)
    {
        DropDownList dropdownlist = (DropDownList)sender;
        if (dropdownlist.SelectedValue == string.Empty)
        {
            dropdownlist.Items[0].Enabled = true;
        }
    }

    protected void SqlDataSourceHardware_Updating(object sender, SqlDataSourceCommandEventArgs e)
    {
        try
        {
            var flpImage = (FileUpload)FormView1.FindControl("ImageFileUpload");
            var hardwareId = ((Label) FormView1.FindControl("HardwareIDLabel")).Text;
            if (flpImage.HasFile)
            {
                var physicalPath = Server.MapPath("~" + path);

                if (File.Exists(physicalPath + hardwareId + Path.GetExtension(flpImage.FileName)))
                {
                    File.Delete(physicalPath + hardwareId + Path.GetExtension(flpImage.FileName));
                }

                var fullImagePath = physicalPath + hardwareId + Path.GetExtension(flpImage.FileName);
                flpImage.SaveAs(fullImagePath);
                e.Command.Parameters["@ImagePath"].Value = path + hardwareId + Path.GetExtension(flpImage.FileName);

                if (allowedExtenstions.Contains(Path.GetExtension(flpImage.FileName).ToLower()))
                {
                    CreateThumbnail(fullImagePath, Convert.ToInt32(ConfigurationManager.AppSettings["allowedWidth"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["allowedHeight"]));
                }
            }
        }
        catch (Exception ex)
        {
            //throw;
        }

    }

    protected void DeleteButton_aspnetSimpleConfirmDelete_Click(object sender, EventArgs e)
    {
        try
        {
            var ImagePath = (HiddenField)FormView1.FindControl("DBImagePath");
            var physicalPath = Server.MapPath(ImagePath.Value);
            if (File.Exists(physicalPath))
            {
                File.Delete(physicalPath);
            }
        }
        catch (Exception)
        {
        }
    }

    public static void CreateThumbnail(string lcFilename, int lnWidth, int lnHeight)
    {

        System.Drawing.Bitmap bmpOut = null;

        try
        {
            Bitmap loBMP = new Bitmap(lcFilename);
            ImageFormat loFormat = loBMP.RawFormat;

            decimal lnRatio;
            int lnNewWidth = 0;
            int lnNewHeight = 0;

            if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
                return;

            if (loBMP.Width > loBMP.Height)
            {
                lnRatio = (decimal)lnWidth / loBMP.Width;
                lnNewWidth = lnWidth;
                decimal lnTemp = loBMP.Height * lnRatio;
                lnNewHeight = (int)lnTemp;
            }
            else
            {
                lnRatio = (decimal)lnHeight / loBMP.Height;
                lnNewHeight = lnHeight;
                decimal lnTemp = loBMP.Width * lnRatio;
                lnNewWidth = (int)lnTemp;
            }


            bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
            Graphics g = Graphics.FromImage(bmpOut);
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
            g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);

            loBMP.Dispose();
        }
        catch
        {
            return;
        }
        bmpOut.Save(lcFilename);
    }
}

ReportViewer Issues

$
0
0

This one is driving me crazy.  When the report path was hard-coded, no issue.  Now that it is a variable it never renders.  Not an issue with data, I can see the data is correct with the visualizer.  It seems to have the correct path, but after after viewer is made visible, no query is run or rendered.

...//code retrieving dataset here

dprt.Fill(dataSet);

ReportViewer1.ProcessingMode = ProcessingMode.Local;

ReportViewer1.LocalReport.DataSources.Clear();

ReportDataSource myRpt = new ReportDataSource("DataSet1",dataSet.Tables[0]);

ReportViewer1.LocalReport.DataSources.Add(myRpt);

ReportViewer1.DataBind();

ReportViewer1.Visible = true;

ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/"+ rptName.ToString() +".rdlc");

ReportView1.LocalReport.Refresh();

I know the code does not encounter any errors during execution as the last line is actually in a TRY..CATCH..FINALLY block and never enters the CATCH.  All the "\" (slash) marks are doubled up for the report path, but first slash is acting as an escape character for the second.

Finally, the report view becomes visible but is formatted weirdly (like filling the DIV reserved for the report and spilling over the footer) instead of the small compact version as one would expect.  Why is this happening? is there a way to format around that.  Never have experience this before.  I have a graphic to illustrate but is not allow me to paste it into this post.

Is there a method to determine to if more than one page is present in Formview?

$
0
0

I have a Formview table controlled by a drop down list.  No problems and the pager is working fine.  However, I would like to know if there is a method to determine if more than one page is present in the Formview display.  Formview clearly shows the number of pages but I would like to add a big red caution to users whenever more than one page exists.  Something like: "Caution, this part is used in more than one place!".

I've searched the web but found very little on this subject.  I'm using Visual Web Designer 2010 in VB.  Thanks!

when I try to open web.config file am getting error message dialogue box saying:value cannot fall within the expected range

$
0
0

I have an mvc and wcf application. It appears suddenly that  when I try to open web.config file by double clicking, am getting  error message dialogue box saying: value cannot fall within the expected range...........

can u help me how to solve this issue

Thanks in Advance

web config 404 problem

$
0
0

I am using visual studio express 2013 and when I try to test my site I get the 404 error. It says web config line 18 has already been added. I can't find where it has been added in any of the other sites.  

I am using windows 8.1 This site was up and now can't get it back up on my browser. Here is the page or part of it.

<?xml version="1.0"?>

<configuration>
  <configSections>
    <section name ="bumplesMagazine" type="EP.BumplesMagazine.BumplesMagazineSection, __code"/>
  </configSections>
  <bumplesMagazine defaultConnectionStringName="BumplesConnectionString">
    <contactForm mailTo="contact@bumples.com"/>
    <newsletters fromEmail="info@bumples.com" fromDisplayName="Bumples Magazine" />
    <store sandboxMode="false" businessEmail="sales@bumples.com" />
  </bumplesMagazine>
  <connectionStrings>
    <!-- Local -->
    <add name="BumplesConnectionString"
         connectionString="Server=server3000; Database=BumplesDataBase; uid=SERVER3000\Junior; Trusted_Connection=True;"
         providerName="System.Data.SqlClient"/>
    <!-- Remote -->
    <add name="BumplesConnectionString" connectionString="Server=mssql1.myregisteredsite.com; Database=27534_BumplesDatabase; User Id=27534_login; Password=9u3673s!; Trusted_Connection=False;"
         providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.net>
    <mailSettings>
      <!-- <smtp deliveryMethod="Network"> 
      <smtp deliveryMethod="PickupDirectoryFromIis" from="support@bumples.com">
        <network defaultCredentials="true" host="(localhost)" port="25" />
      </smtp>
      -->
      <smtp from="info@bumples.com">
        <network host="smtp.bumples.com" password="gr!77y09" userName="info@bumples.com"/>
      </smtp>
    </mailSettings>
  </system.net>
  <system.web>
    hope some one can help me get the site back up at bumples.com

Thanks


Jennifer Sheehan

Trying to Debug Directly in VStudio

$
0
0

I have to do some work on an existing codebase that has this folder structure:

\root
   ECommerce
      Common
      Images
        sitenameA
      Scripts
      Sites
        sitenameA  <<< This is the startup project >>>
           bin
           Controls
           MasterPages
           obj
      Styles
        sitenameA
   Infrastructure
      Binaries
      General.Client.Common
      General.Common
      General.Server.BusinessLayer
      General.Server.ServiceLayer

The previous developer told me that the only way to debug this application is to:

  1. Start a browser.
  2. Navigate to the deployed website.
  3. In Visual Studio, attach to the browser.
  4. Go through the web app and debug.

This is fine when I'm ready to test the deployed version running in IIS but, for starters, I would just like to be able to go through the regular Run-Debug cycle entirely within Visual Studio.  The PROBLEM is that everything in ECommerce, in another area outside of "Sites\sitenameA", isn't referenced within the "sitenameA" project.

I've just never seen a VStudio solution organized this way but understand it makes sense in this case because there's a "sitenameB", "sitenameC", etc.

If you were in my shoes, how would you get it to run in Debug mode in VStudio?

Robert

Develop a forum as part of a website

$
0
0

Hi,
I am making a website on Visual Studio web 2012 and I have to include a forum as part of it.
Therefore, I was wondering if anyone has some experience in developing forum under VS2012, could share it. Maybe redirect me to a tutorial or maybe source code.

Also, I will point that I am not interested in some third parties forum host, or any forum template companies. The main reason being that I am planning on modifying some element of regular forum, and this is why getting some forum source code  or tutorial under VS2012 will be the best option.

Thank you.


How to automatically zip Html/css/js/image files when switching to release version?

$
0
0

Hello all:

Web Essential is a very very nice tool for web's development.

However I'd like to automatically zip Html/css/js/image files when switching to release version.

For debug version, do nothing.

How to do with that?

Many thanks!

Visual Studio 2013 Pro

$
0
0

Dear All,

We are  in planning to upgrade some of our old projects which are in asp and vb to .net. so for that thinking to buy the below software and server. for database we will continue with slq 2000 which we have already.

1.]vs2013 professional license for 4 developers

2.]window server 2008 r2 for web server for those web sites which will migrate to .net from asp.

and as well thinking to buy vs2013 professional without msdn. 

so my questions are

1.]is there anything missing to buy or think for the upgrade?

2.]what is different if we buy without  msdn for vs2013 professional?

looking for your valuable advice

Regards,

Mk

Getting loading test for testmethod in test explore window in Visual Studio 2013 for Xunit

$
0
0

HI,

When I am trying to run the test method in test class, the test case get pass but the details in the method or name just showing as "Loading" see attached email. I tried with various ways to get the details but no luck.

I am not using any entity framework but still getting error as in output window 

 "Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest."

Please help

Modify what is collapsed in Outlining

$
0
0

Is there a way to modify what is considered Outlining (what would be collapsed by a Ctrl+M, Ctrl+L via Edit.ToggleAllOutlining)?

Specifically I would like to not toggle namespaces, classes, and for loops.

Thanks!

Webs form project and MS video

$
0
0

Hello

According to this 3-min MS video http://www.asp.net/aspnet/overview/aspnet-and-visual-studio-2012/oauth-in-the-default-aspnet-45-templates , if I open up a new Web forms project, it creates a new folder called App_Start in which there is a file called Auth_Config.

I have Visual Studio Express 2013 for Web and can't see that file anywhere: Files

Does my version of VS allow me to set up my project so that users can log in to my  ASP.NET (VB.NET) Login.aspx form through Twitter, etc, as the above video demonstrates?

Thank you.

Viewing all 3509 articles
Browse latest View live




Latest Images