Search Results

Search found 390 results on 16 pages for 'clientid'.

Page 1/16 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Take Control Of Web Control ClientID Values in ASP.NET 4.0

    Each server-side Web control in an ASP.NET Web Forms application has an ID property that identifies the Web control and is name by which the Web control is accessed in the code-behind class. When rendered into HTML, the Web control turns its server-side ID value into a client-side id attribute. Ideally, there would be a one-to-one correspondence between the value of the server-side ID property and the generated client-side id, but in reality things aren't so simple. By default, the rendered client-side id is formed by taking the Web control's ID property and prefixed it with the ID properties of its naming containers. In short, a Web control with an ID of txtName can get rendered into an HTML element with a client-side id like ctl00_MainContent_txtName. This default translation from the server-side ID property value to the rendered client-side id attribute can introduce challenges when trying to access an HTML element via JavaScript, which is typically done by id, as the page developer building the web page and writing the JavaScript does not know what the id value of the rendered Web control will be at design time. (The client-side id value can be determined at runtime via the Web control's ClientID property.) ASP.NET 4.0 affords page developers much greater flexibility in how Web controls render their ID property into a client-side id. This article starts with an explanation as to why and how ASP.NET translates the server-side ID value into the client-side id value and then shows how to take control of this process using ASP.NET 4.0. Read on to learn more! Read More >

    Read the article

  • Take Control Of Web Control ClientID Values in ASP.NET 4.0

    Each server-side Web control in an ASP.NET Web Forms application has an ID property that identifies the Web control and is name by which the Web control is accessed in the code-behind class. When rendered into HTML, the Web control turns its server-side ID value into a client-side id attribute. Ideally, there would be a one-to-one correspondence between the value of the server-side ID property and the generated client-side id, but in reality things aren't so simple. By default, the rendered client-side id is formed by taking the Web control's ID property and prefixed it with the ID properties of its naming containers. In short, a Web control with an ID of txtName can get rendered into an HTML element with a client-side id like ctl00_MainContent_txtName. This default translation from the server-side ID property value to the rendered client-side id attribute can introduce challenges when trying to access an HTML element via JavaScript, which is typically done by id, as the page developer building the web page and writing the JavaScript does not know what the id value of the rendered Web control will be at design time. (The client-side id value can be determined at runtime via the Web control's ClientID property.) ASP.NET 4.0 affords page developers much greater flexibility in how Web controls render their ID property into a client-side id. This article starts with an explanation as to why and how ASP.NET translates the server-side ID value into the client-side id value and then shows how to take control of this process using ASP.NET 4.0. Read on to learn more! Read More >Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Cleaner ClientID's with ASP.NET 4.0

    - by amaniar
    Normal 0 false false false EN-US X-NONE HI /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; mso-bidi-font-size:10.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} A common complain we have had when using ASP.NET web forms is the inability to control the ID attributes being rendered in the HTML markup when using server controls. Our Interface Engineers want to be able to predict the ID’s of controls thereby having more control over their client side code for selecting/manipulating elements by ID or using CSS to target them. While playing with the just released VS2010 and .NET 4.0 I discovered some real cool improvements. One of them is the ability to now have full control over the ID being rendered for server controls. ASP.NET 4.0 controls now have a new ClientIDMode property which gives the developer complete control over the ID’s being rendered making it easy to write JavaScript and CSS against the rendered html. By default the ClientIDMode is set to Predictable which results in clean and predictable ID’s by concatenating the ID’s of the Parent and child controls. So the following markup: <asp:Content ID="ParentContainer" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">     <asp:Label runat="server" ID="MyLabel">My Label</asp:Label> </asp:Content>                                                                                                                                                             Will render:   <span id="ParentContainer_MyLabel">My Label</span> Instead of something like this: (current) <span id="ct100_ParentContainer_MyLabel">My Label</span> Other modes include AutoID (renders ID’s like it currently does in .NET 3.5), Static (renders the ID exactly as specified in the code) and Inherit (defers the mode to the parent control). So now I can write my jQuery selector as: $(“ParentContainer_MyLabel”).text(“My new Text”); Instead of: $(‘<%=this. MyLabel.ClientID%>’).text(“My new Text”); Scott Mitchell has a great article about this new feature: http://bit.ly/ailEJ2 Am excited about this and some other improvements. Many thanks to the ASP.NET team for Listening!

    Read the article

  • ASP.NET javascript. Put it in code behind or put it in .aspx file?

    - by punkouter
    Why do people put javascript in the code behind ? I think it is ugly to have 100 (see below) of these.... Is there some basic reasons that javascript must be in the code behind in some instances? And when it should in the aspx. ?? // now we gotta recalc fields szCalcBenefitsTotal += " CalcCostFromPct('" + tbSocialSecurityPercent3.ClientID + "', '" + tbSocialSecurity3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');"; szCalcBenefitsTotal += " CalcCostFromPct('" + tbMedicarePercent3.ClientID + "', '" + tbMedicare3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');"; szCalcBenefitsTotal += " CalcCostFromPct('" + tbHealthInsurancePercent3.ClientID + "', '" + tbHealthInsurance3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');"; szCalcBenefitsTotal += " CalcCostFromPct('" + tbLifeInsurancePercent3.ClientID + "', '" + tbLifeInsurance3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');"; szCalcBenefitsTotal += " CalcCostFromPct('" + tbVacationPercent3.ClientID + "', '" + tbVacation3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');"; szCalcBenefitsTotal += " CalcCostFromPct('" + tbSickLeavePercent3.ClientID + "', '" + tbSickLeave3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');"; szCalcBenefitsTotal += " CalcCostFromPct('" + tbRetirementPercent3.ClientID + "', '" + tbRetirement3.ClientID + "', '" + tbSalaryAdjusted3.ClientID + "');";

    Read the article

  • Take Control Of Web Control ClientID Values in ASP.NET 4.0

    Each server-side Web control in an ASP.NET Web Forms application has an <code>ID</code> property that identifies the Web control and is name by which the Web control is accessed in the code-behind class. When rendered into HTML, the Web control turns its server-side <code>ID</code> value into a client-side <code>id</code> attribute. Ideally, there would be a one-to-one correspondence between the value of the server-side <code>ID</code> property and the generated client-side <code>id</code>, but in reality things aren't so simple. By default, the rendered client-side <code>id</code> is formed by taking the Web control's <code>ID</code> property and prefixed it with the <code>ID</code>

    Read the article

  • How to call SQL Function with multiple parameters from C# web page

    - by Marshall
    I have an MS SQL function that is called with the following syntax: SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE ClientID = 7 AND LocationName = ''Default'' ', 10) The first parameter passes a specific WHERE clause that is used by the function for one of the internal queries. When I call this function in the front-end C# page, I need to send parameter values for the individual fields inside of the WHERE clause (in this example, both the ClientID & LocationName fields) The current C# code looks like this: String SQLText = "SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE ClientID = @ClientID AND LocationName = @LocationName ',10)"; SqlCommand Cmd = new SqlCommand(SQLText, SqlConnection); Cmd.Parameters.Add("@ClientID", SqlDbType.Int).Value = 7; // Insert real ClientID Cmd.Parameters.Add("@LocationName", SqlDbType.NVarChar(20)).Value = "Default"; // Real code uses Location Name from user input SqlDataReader reader = Cmd.ExecuteReader(); When I do this, I get the following code from SQL profiler: exec sp_executesql N'SELECT Field1, COUNT(*) as RecordCount FROM GetDecileTable (''WHERE ClientID = @ClientID AND LocationName = @LocationName '',10)', N'@ClientID int,@LocationID nvarchar(20)', @ClientID=7,@LocationName=N'Default' When this executes, SQL throws an error that it cannot parse past the first mention of @ClientID stating that the Scalar Variable @ClientID must be defined. If I modify the code to declare the variables first (see below), then I receive an error at the second mention of @ClientID that the variable already exists. exec sp_executesql N'DECLARE @ClientID int; DECLARE @LocationName nvarchar(20); SELECT Field1, COUNT(*) as RecordCount FROM GetDecileTable (''WHERE ClientID = @ClientID AND LocationName = @LocationName '',10)', N'@ClientID int,@LocationName nvarchar(20)', @ClientID=7,@LocationName=N'Default' I know that this method of adding parameters and calling SQL code from C# works well when I am selecting data from tables, but I am not sure how to embed parameters inside of the ' quote marks for the embedded WHERE clause being passed to the function. Any ideas?

    Read the article

  • Get controls ClientID/UniqueID between DetailsView and UpdatePanel

    - by robertpnl
    Hi guys, I like to know how to get the ClientID/UniqueID of a control inside a Detailsview controls EditItemTemplate element and when DetailsViews changing to Edit mode and DetailsView is inside a AJAX UpdatePanel. Without UpdatePanel, during PostBack I can get the ClientID's control, but now with an UpdatePanel. <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" AutoGenerateEditButton="true"> <Fields> <asp:TemplateField> <EditItemTemplate> <asp:CheckBox runat="server" ID="chkboxTest" Text="CHECKBOX" /> </EditItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView> </ContentTemplate> </asp:UpdatePanel> As you see, the EditItemTemplate contains a Checkbox control. So i'm trying to get the ClientID of this checkbox when Detailsview is changing to the Edit mode. I need this value for handling Javascript. Catching the events ChangingMode/ChangedMode doesn't work; chkbox is null: void DetailsView1_ModeChanged(object sender, EventArgs e) { if (DetailsView1.CurrentMode == DetailsViewMode.Edit) var chkbox = DetailsView1.Rows[0].FindControl("chkxboxTest"); // <== is null } Maybe i'm using the wrong event? Someone can give me a tip about this? Thanks.

    Read the article

  • RichFaces rich:clientId within facelets

    - by Matthias Hryniszak
    Hi there, I'm trying to something like this: <?xml version="1.0"/> <ui:composition ....> <h:inputText id="#{id}InputText" value="#{value}"/> <rich:calendar id="#{id}Shevron" popup="true" datePattern="ddMMyy" showInput="false" todayControlMode="hidden" enableManualInput="false" showApplyButton="false" updateDays="14" ondateselected="alert('#{rich:clientId('#{id}Shevron')}');" inputClass="xwingml-input"/> </ui:composition> The problem I'm facing here is that the actual client id is generated for my facelts components. Is there a way to pass an id to rich:clientId like this? If not how would one go about this kind of problem? Thanks in advance!.

    Read the article

  • Get clientid in user control from external javascript file

    - by Giorgi
    Hello, I am developing a user control (ascx) in ASP.NET which uses javascript for manipulating controls. Currently the javascript code is inlined and uses <%= somecontrol.ClientID %> to get the control it needs. I want to put the javascript file in external file but from external file I cannot use the above syntax for retrieving controls. I have read about possible solutions in this and this answers but the problem is that the user control can be placed multiple times on page. This means that the Controls array (mentioned in the answers) will be rendered several times with different items. As a result the script will not be able to retrieve the id it needs. If I put <%= ClientId %> in the name of array that holds items then I will have the same problem as I am trying to solve. Any ideas?

    Read the article

  • Extending web server controls by providing client side functionality through Javascript

    - by nikolaosk
    In this post I will demonstrate how to extend the functionality of the web server controls by adding client side functionality with Javascript. Let's move on to our example. 1) Launch Visual Studio 2010/2008/2005. (express editions will work fine). Create a new empty website and choose a suitable name for it. 2) Add a new item in your site, a web form. Leave the default name. 3) We need to add some markup. < form id = "form1" runat = "server" > < div > < span id = "test1" > nikos...(read more)

    Read the article

  • ASP: button to input submit

    - by vishnu
    Hi All, I am trying to use literalcontrol to add a button as input type="submit" litLevelList.Text += string.Format(" &lt input type='submit' id='{0}' value='{1}' name='{2}' >", btnSave.ClientID, Lang.Trans("Save Changes " ) , btnSave. ??); I could get the button ID using CLientID but without the name the data doesnt seems to be submitted. Could anyone tell me how i could access the name value rendered by ASP for a button control. thanks, vishnu

    Read the article

  • Accessing a control in asp.net content page through Javascript

    - by rocksolid
    Hi, I have a form in my content page for which I am doing some client side validations via Javascript. The Javascript behaves as expected if I place the JS code directly in the content page. But if I place the JS code in it's own file and try accessing that from the content/master page (through the script tag's src attribute), I get a run time error when the validation function in JS being called. To be specific, I get the below error. Microsoft JScript runtime error: Objected expected/required at this line - document.getElementById('<%=txtemailId.ClientID %').value txtemailId is in the content page. Javascript code is placed in validation.js and accessed via master page. The reason I guess is that when .net is parsing the files, it is unable to substitute txtemailId.ClientID with the client side value that would be generated later on. So, how should one go about it? Thanks!

    Read the article

  • Client Id for Property (ASP.Net MVC)

    - by Felipe
    Hi guys... I'm begginer in asp.net mvc, and i have a doubs: I'm trying to do a label for a TextBox in my View and I'd like to know, how can I take a Id that will be render in client to generete scripts... for example: <label for="<%=x.Name.?ClientId?%>"> Name: </label> <%=Html.TextBoxFor(x=>x.Name) %> What need I put in "?ClientId?" to make sure that correct Id will be render to the corresponding control ? Thanks Cheers

    Read the article

  • At what asp.net page event are clientIDs assigned?

    - by user191272
    I want to do something like this: Panel divPanel = new Panel(); divPanel.ID = "divPanel"; this.Page.Controls.Add(divPanel); string script = "function alertID(){alert("the id is: "+divPanel.ClientID+");}"; this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scripttests", script); But when I put this code in page_load, I don't get the full id, which is ctl00_ContentMain_divPanel, I just get divPanel. Is there another event I should use? How do I make this work?

    Read the article

  • passing data from a client form via jquery ajax dinamicly

    - by quantum62
    i wanna insert specification of members that enter in textboxs of form in the database .i do this operation with jquery ajax when i call webmetod with static value the operation do successfully.for example this code is ok. $.ajax({ type: "POST", url:"MethodInvokeWithJQuery.aspx/executeinsert", data: '{ "username": "user1", "name":"john","family":"michael","password":"123456","email": "[email protected]", "tel": "123456", "codemeli": "123" }', contentType: "application/json; charset=utf-8", dataType: "json", async: true, cache: false, success: function (msg) { $('#myDiv2').text(msg.d); }, error: function (x, e) { alert("The call to the server side failed. " + x.responseText); } } ); but when i wanna use of values that enter in textboxes dynamically error occur.whats problem?i try this two code <script type="text/javascript"> $(document).ready( function () { $("#Button1").click( function () { var username, family, name, email, tel, codemeli, password; username = $('#<%=TextBox1.ClientID%>').val(); name = $('#<%=TextBox2.ClientID%>').val(); family = $('#<%=TextBox3.ClientID%>').val(); password = $('#<%=TextBox4.ClientID%>').val(); email = $('#<%=TextBox5.ClientID%>').val(); tel = $('#<%=TextBox6.ClientID%>').val(); codemeli = $('#<%=TextBox7.ClientID%>').val(); $.ajax( { type: "POST", url: "WebApplication20.aspx/executeinsert", data: "{'username':'username','name':name, 'family':family,'password':password, 'email':email,'tel':tel, 'codemeli':codemeli}", contentType: "application/json;charset=utf-8", dataType: "json", async: true, cache: false, success: function(msg) { alert(msg); }, error: function (x, e) { alert("The call to the server side failed. " + x.responseText); } } ); } ) }) </script> or $(document).ready( function () { $("#Button1").click( function () { var username, family, name, email, tel, codemeli, password; username = $('#<%=TextBox1.ClientID%>').val(); name = $('#<%=TextBox2.ClientID%>').val(); family = $('#<%=TextBox3.ClientID%>').val(); password = $('#<%=TextBox4.ClientID%>').val(); email = $('#<%=TextBox5.ClientID%>').val(); tel = $('#<%=TextBox6.ClientID%>').val(); codemeli = $('#<%=TextBox7.ClientID%>').val(); $.ajax( { type: "POST", url: "WebApplication20.aspx/executeinsert", data: '{"username" : '+username+', "name": '+name+', "family": '+family+', "password": '+password+', "email": '+email+', "tel": '+tel+' , "codemeli": '+codemeli+'}', contentType: "application/json;charset=utf-8", dataType: "json", async: true, cache: false, success: function(msg) { alert(msg); }, error: function (x, e) { alert("The call to the server side failed. " + x.responseText); } } ); } ) })

    Read the article

  • Stupid problem with Javascript calculations and postbacks

    - by rockinthesixstring
    I'm working on an ASP.NET web app where I'm using a Wizard to take the client through a large series of steps. One of the steps includes calculating a bunch of numbers on the fly... the numbers calculate properly but when I click "next" and then go back again... some of the numbers are not retained. Here is the calculation function function CalculateFields() { txtSellingPrice = document.getElementById('<%=txtSellingPrice.ClientID %>'); txtBalanceSheet = document.getElementById('<%=txtBalanceSheet.ClientID %>'); txtDownPayment = document.getElementById('<%=txtDownPayment.ClientID %>'); txtSusEarn = document.getElementById('<%=txtSusEarn.ClientID %>'); txtSusRev = document.getElementById('<%=txtSusRev.ClientID %>'); txtBalanceMult = document.getElementById('<%=txtBalanceMult.ClientID %>'); txtGoodwillMult = document.getElementById('<%=txtGoodwillMult.ClientID %>'); txtSellingPriceMult = document.getElementById('<%=txtSellingPriceMult.ClientID %>'); txtGoodWill = document.getElementById('<%=txtGoodWill.ClientID %>'); txtBalance = document.getElementById('<%=txtBalance.ClientID %>'); chkTakeBack = document.getElementById('<%=chkTakeBack.ClientID %>'); txtVendorTakeBackPercentage = document.getElementById('<%=txtVendorTakeBackPercentage.ClientID %>'); txtSusEarnPercentage = document.getElementById('<%=txtSusEarnPercentage.ClientID %>'); txtBalanceMultPercentage = document.getElementById('<%=txtBalanceMultPercentage.ClientID %>'); txtGoodwillMultPercentage = document.getElementById('<%=txtGoodwillMultPercentage.ClientID %>'); txtSellingPriceMultPercentage = document.getElementById('<%=txtSellingPriceMultPercentage.ClientID %>'); var regexp = /[$,]/g; //Empty value checks SellingPrice = (SellingPrice == "" ? "$0" : SellingPrice); BalanceSheet = (BalanceSheet == "" ? "$0" : BalanceSheet); DownPayment = (DownPayment == "" ? "$0" : DownPayment); susearn = (susearn == "" ? "$0" : susearn); susrev = (susrev == "" ? "$0" : susrev); balmult = (balmult == "" ? "$0" : balmult); goodmult = (goodmult == "" ? "$0" : goodmult); sellmult = (sellmult == "" ? "$0" : sellmult); //Replace $ with String.Empty SellingPrice = txtSellingPrice.value.replace(regexp, ""); BalanceSheet = txtBalanceSheet.value.replace(regexp, ""); DownPayment = txtDownPayment.value.replace(regexp, ""); susearn = txtSusEarn.value.replace(regexp, ""); susrev = txtSusRev.value.replace(regexp, ""); balmult = txtBalanceMult.value.replace(regexp, ""); goodmult = txtGoodwillMult.value.replace(regexp, ""); sellmult = txtSellingPriceMult.value.replace(regexp, ""); //Set the new values txtGoodWill.value = "$" + (SellingPrice - BalanceSheet); txtBalance.value = "$" + (SellingPrice - DownPayment); txtSellingPriceMult.value = "$" + SellingPrice; txtGoodwillMult.value = "$" + (SellingPrice - BalanceSheet); txtBalanceMult.value = "$" + BalanceSheet; if (chkTakeBack.checked == 1) { txtVendorTakeBackPercentage.value = Math.round((SellingPrice - DownPayment) / SellingPrice * 100); } else { txtVendorTakeBackPercentage.value = "0"; } if (!(susearn == "") && !(susearn == "0") && !(susearn == "$0")) { txtSusEarnPercentage.value = Math.round(susearn / susrev * 100); txtBalanceMultPercentage.value = Math.round(balmult / susearn); txtGoodwillMultPercentage.value = Math.round(goodmult / susearn); txtSellingPriceMultPercentage.value = Math.round(sellmult / susearn); } else { txtSusEarnPercentage.value = "0"; txtBalanceMultPercentage.value = "0"; txtGoodwillMultPercentage.value = "0"; txtSellingPriceMultPercentage.value = "0"; } } all of these calculate properly and retain their value across postbacks txtGoodWill.value = "$" + (SellingPrice - BalanceSheet); txtBalance.value = "$" + (SellingPrice - DownPayment); txtSellingPriceMult.value = "$" + SellingPrice; txtGoodwillMult.value = "$" + (SellingPrice - BalanceSheet); txtBalanceMult.value = "$" + BalanceSheet; These ones however do not retain their value across postbacks if (chkTakeBack.checked == 1) { txtVendorTakeBackPercentage.value = Math.round((SellingPrice - DownPayment) / SellingPrice * 100); } else { txtVendorTakeBackPercentage.value = "0"; } if (!(susearn == "") && !(susearn == "0") && !(susearn == "$0")) { txtSusEarnPercentage.value = Math.round(susearn / susrev * 100); txtBalanceMultPercentage.value = Math.round(balmult / susearn); txtGoodwillMultPercentage.value = Math.round(goodmult / susearn); txtSellingPriceMultPercentage.value = Math.round(sellmult / susearn); } else { txtSusEarnPercentage.value = "0"; txtBalanceMultPercentage.value = "0"; txtGoodwillMultPercentage.value = "0"; txtSellingPriceMultPercentage.value = "0"; } The txtVendorTakeBackPercentage always comes back BLANK and the other three always come back as 0 I'm firing these functions by using the onkeyup event within the form fields. If Not Page.IsPostBack Then txtSellingPrice.Attributes.Add("onkeyup", "CalculateFields()") txtBalanceSheet.Attributes.Add("onkeyup", "CalculateFields()") txtDownPayment.Attributes.Add("onkeyup", "CalculateFields()") txtSusRev.Attributes.Add("onkeyup", "CalculateFields()") txtSusEarn.Attributes.Add("onkeyup", "CalculateFields()") End If any thoughts/help/direction would be greatly appreciated.

    Read the article

  • SQL - date variable isn't being parsed correctly?

    - by Bill Sambrone
    I am pulling a list of invoices filtered by a starting and ending date, and further filtered by type of invoice from a SQL table. When I specify a range of 2013-07-01 through 2013-09-30 I am receiving 2 invoices per company when I expect 3. When I use the built in select top 1000 query in SSMS and add my date filters, all the expected invoices appear. Here is my fancy query that I'm using that utilizing variables that are fed in: DECLARE @ReportStart datetime DECLARE @ReportStop datetime SET @ReportStart = '2013-07-01' SET @ReportStop = '2013-09-30' SELECT Entity_Company.CompanyName, Reporting_AgreementTypes.Description, Reporting_Invoices.InvoiceAmount, ISNULL(Reporting_ProductCost.ProductCost,0), (Reporting_Invoices.InvoiceAmount - ISNULL(Reporting_ProductCost.ProductCost,0)), (Reporting_AgreementTypes.Description + Entity_Company.CompanyName), Reporting_Invoices.InvoiceDate FROM Reporting_Invoices JOIN Entity_Company ON Entity_Company.ClientID = Reporting_Invoices.ClientID LEFT JOIN Reporting_ProductCost ON Reporting_ProductCost.InvoiceNumber =Reporting_Invoices.InvoiceNumber JOIN Reporting_AgreementTypes ON Reporting_AgreementTypes.AgreementTypeID = Reporting_Invoices.AgreementTypeID WHERE Reporting_Invoices.AgreementTypeID = (SELECT AgreementTypeID FROM Reporting_AgreementTypes WHERE Description = 'Resold Services') AND Reporting_Invoices.InvoiceDate >= @ReportStart AND Reporting_Invoices.InvoiceDate <= @ReportStop ORDER BY CompanyName,InvoiceDate The above only returns 2 invoices per company. When I run a much more basic query through SSMS I get 3 as expected, which looks like: SELECT TOP 1000 [InvoiceID] ,[AgreementID] ,[AgreementTypeID] ,[InvoiceDate] ,[Comment] ,[InvoiceAmount] ,[InvoiceNumber] ,[TicketID] ,Entity_Company.CompanyName FROM Reporting_Invoices JOIN Entity_Company ON Entity_Company.ClientID = Reporting_Invoices.ClientID WHERE Entity_Company.ClientID = '9' AND AgreementTypeID = (SELECT AgreementTypeID FROM Reporting_AgreementTypes WHERE Description = 'Resold Services') AND Reporting_Invoices.InvoiceDate >= '2013-07-01' AND Reporting_Invoices.InvoiceDate <= '2013-09-30' ORDER BY InvoiceDate DESC I've tried stripping down the 1st query to include only a client ID on the original invoice table, the invoice date, and nothing else. Still only get 2 invoices instead of the expected 3. I've also tried manually entering the dates instead of the @ variables, same result. I confirmed that InvoiceDate is defined as a datetime in the table. I've tried making all JOIN's a FULL JOIN to see if anything is hiding, but no change. Here is how I stripped down the original query to keep all other tables out of the mix and yet I'm still getting only 2 invoices per client ID instead of 3 (I manually entered the ID for the type filter): --DECLARE @ReportStart datetime --DECLARE @ReportStop datetime --SET @ReportStart = '2013-07-01' --SET @ReportStop = '2013-09-30' SELECT --Entity_Company.CompanyName, --Reporting_AgreementTypes.Description, Reporting_Invoices.ClientID, Reporting_Invoices.InvoiceAmount, --ISNULL(Reporting_ProductCost.ProductCost,0), --(Reporting_Invoices.InvoiceAmount - ISNULL(Reporting_ProductCost.ProductCost,0)), --(Reporting_AgreementTypes.Description + Entity_Company.CompanyName), Reporting_Invoices.InvoiceDate FROM Reporting_Invoices --JOIN Entity_Company ON Entity_Company.ClientID = Reporting_Invoices.ClientID --LEFT JOIN Reporting_ProductCost ON Reporting_ProductCost.InvoiceNumber = Reporting_Invoices.InvoiceNumber --JOIN Reporting_AgreementTypes ON Reporting_AgreementTypes.AgreementTypeID = Reporting_Invoices.AgreementTypeID WHERE Reporting_Invoices.AgreementTypeID = '22'-- (SELECT AgreementTypeID FROM Reporting_AgreementTypes WHERE Description = 'Resold Services') AND Reporting_Invoices.InvoiceDate >= '2013-07-01' AND Reporting_Invoices.InvoiceDate <= '2013-09-30' ORDER BY ClientID,InvoiceDate This strikes me as really weird as it is pretty much the same query as the SSMS generated one that returns correct results. What am I overlooking? UPDATE I've further refined my "test query" that is returning only 2 invoices per company to help troubleshoot this. Below is the query and a relevant subset of data for 1 company from the appropriate tables: SELECT Reporting_Invoices.ClientID, Reporting_AgreementTypes.Description, Reporting_Invoices.InvoiceAmount, Reporting_Invoices.InvoiceDate FROM Reporting_Invoices JOIN Reporting_AgreementTypes ON Reporting_AgreementTypes.AgreementTypeID = Reporting_Invoices.AgreementTypeID WHERE Reporting_Invoices.AgreementTypeID = (SELECT AgreementTypeID FROM Reporting_AgreementTypes WHERE Description = 'Resold Services') AND Reporting_Invoices.InvoiceDate >= '2013-07-01T00:00:00' AND Reporting_Invoices.InvoiceDate <= '2013-09-30T00:00:00' ORDER BY Reporting_Invoices.ClientID,InvoiceDate The above only returns 2 invoices. Here is the relevant table data: Relevant data from Reporting_AgreementTypes AgreementTypeID Description 22 Resold Services Relevant data from Reporting_Invoices InvoiceID ClientID AgreementID AgreementTypeID InvoiceDate 16111 9 757 22 2013-09-30 00:00:00.000 15790 9 757 22 2013-08-30 00:00:00.000 15517 9 757 22 2013-07-31 00:00:00.000 Actual results from my new modified query ClientID Description InvoiceAmount InvoiceDate 9 Resold Services 3513.79 7/31/13 00:00:00 9 Resold Services 3570.49 8/30/13 00:00:00

    Read the article

  • ASP.NET MVC 2: Linq to SQL entity w/ ForeignKey relationship and Default ModelBinder strangeness

    - by Simon
    Once again I'm having trouble with Linq to Sql and the MVC Model Binder. I have Linq to Sql generated classes, to illustrate them they look similar to this: public class Client { public int ClientID { get; set; } public string Name { get; set; } } public class Site { public int SiteID { get; set; } public string Name { get; set; } } public class User { public int UserID { get; set; } public string Name { get; set; } public int? ClientID { get; set; } public EntityRef<Client> Client { get; set; } public int? SiteID { get; set; } public EntityRef<Site> Site { get; set; } } The 'User' has a relationship with the 'Client' and 'Site . The User class has nullable ClientIDs and SiteIDs because the admin users are not bound to a Client or Site. Now I have a view where a user can edit a 'User' object, the view has fields for all the 'User' properties. When the form is submitted, the appropiate 'Save' action is called in my UserController: public ActionResult Save(User user, FormCollection form) { //form['SiteID'] == 1 //user.SiteID == 1 //form['ClientID'] == 1 //user.ClientID == null } The problem here is that the ClientID is never set, it is always null, even though the value is in the FormCollection. To figure out whats going wrong I set breakpoints for the ClientID and SiteID getters and setters in the Linq to Sql designer generated classes. I noticed the following: SiteID is being set, then ClientID is being set, but then the Client EntityRef property is being set with a null value which in turn is setting the ClientID to null too! I don't know why and what is trying to set the Client property, because the Site property setter is never beeing called, only the Client setter is being called. Manually setting the ClientID from the FormCollection like this: user.ClientID = int.Parse(form["ClientID"].ToString()); throws a 'ForeignKeyReferenceAlreadyHasValueException', because it was already set to null before. The only workaround I have found is to extend the generated partial User class with a custom method: Client = default(EntityRef<Client>) but this is not a satisfying solution. I don't think it should work like this? Please enlighten me someone. So far Linq to Sql is driving me crazy! Best regards

    Read the article

  • textbox required equal false

    - by Donato bruno comunali F. dutra
    how do I make the textbox that required equal to false in this code $(document).ready(function () { $("#<%= chkSpecialIntegration.ClientID %>").click(function () { if (this.checked) { $("#<%= ddlTypeSpecialIntegration.ClientID %>").show(); document.getElementById('<%=txtTotalScoreDebit.ClientID %>').Required = false; } else{ $("#<%= ddlTypeSpecialIntegration.ClientID %>").hide(); document.getElementById('<%=txtTotalScoreDebit.ClientID %>').Required = true; } }); });

    Read the article

  • Why is my content being overwritten instead of replaced in jQuery/Ajax?

    - by Matt Nathanson
    I've got jquery being used in ajax to pass some contents into a database, my problem however has nothing to do with the db.. I have input fields in an id called #clientscontainer. When I click "save" in that container, it automatically refreshes the container correctly ... $('#clientscontainer').html(html); The problem is, a couple of those input fields (such as a description and title), have instances in another div that i want to refresh upon the save click. The other ID is: $('div#' + clientID') When I do $('div#' + clientID').html(html); it refreshes the content from clientscontainer in it instead of just the variables that I want to update. When I try to pass just the variable $(blurb).html(html); it updates the blurb but it ONLY displays that variable in the div# clientID div... whereas I just want to replace it. Here is the AJAX portion of the function ...//variables// dataToLoad = 'clientID=' + clientID + '&changeClient=yes' + '&project=' + descriptionSubTitle + '&campaign=' + descriptionTitle + '&label=' + descriptionLabel + '&descriptionedit=' + description + '&blurbedit=' + blurb; $.ajax({ type: 'post', url: ('/clients/controller.php'), datatype: 'html', data: dataToLoad, success: function(html){ dataToLoad = 'clientID=' + clientID + '&loadclient=yes&isCMS=' + editCMS; $.ajax({ type: 'post', url: '/clients/controller.php', datatype: 'html', data: dataToLoad, async: false, success: function(html){ //$('#clientscontainer').focus(function() {reInitialize()}); //$('#clientscontainer').ajaxComplete(function(){reInitialize()}); $('#clientscontainer').html(html); $('div#' + clientID).each(function(){ $('#editbutton').click(function() {EditEverything()}); } , error: function() { alert('An error occured! 222'); } });}, error: function() { alert('An error occured! 394'); } }); any suggestions?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >