Search Results

Search found 23 results on 1 pages for 'user208662'.

Page 1/1 | 1 

  • JavaScript - Building JSON object

    - by user208662
    Hello, I'm trying to understand how to build a JSON object in JavaScript. This JSON object will get passed to a JQuery ajax call. Currently, I'm hard-coding my JSON and making my JQuery call as shown here: $.ajax({ url: "/services/myService.svc/PostComment", type: "POST", contentType: "application/json; charset=utf-8", data: '{"comments":"test","priority":"1"}', dataType: "json", success: function (res) { alert("Thank you!"); }, error: function (req, msg, obj) { alert("There was an error"); } }); This approach works. But, I need to dynamically build my JSON and pass it onto the JQuery call. However, I cannot figure out how to dynamically build the JSON object. Currently, I'm trying the following without any luck: var comments = $("#commentText").val(); var priority = $("#priority").val(); var json = { "comments":comments,"priority":priority }; $.ajax({ url: "/services/myService.svc/PostComment", type: "POST", contentType: "application/json; charset=utf-8", data: json, dataType: "json", success: function (res) { alert("Thank you!"); }, error: function (req, msg, obj) { alert("There was an error"); } }); Can someone please tell me what I am doing wrong? I noticed that with the second version, my service is not even getting reached. Thank you

    Read the article

  • ASP.NET GridView - Editing Dynamic Template Columns

    - by user208662
    Hello, I have created a GridView whose columns are dynamically created based on my data source. I have implemented these columns by using the approach described here.Those columns display properly on the initial load. However, I need to implement commanding so that a user can edit / delete a row in the GridView. At this point, I have implemented commanding as I would with a normal GridView. I have a TemplateField with an ItemTemplate that has LinkButton elements for edit and delete. The CommandName for each LinkButton is set to either Edit or Delete respectively. Oddly, when a user clicks either the Edit or Delete link, the data in the GridView disappears. However, I have verified that I am in fact re-binding the data when one of these LinkButton elements is selected. Can anyone provide some suggestions as to what the cause could be? Thank you!

    Read the article

  • ASP.NET / WCF - Execute Server.Execute Asynchronously

    - by user208662
    Hello, I need to run the HttpContext.Current.Server.Execute method in my ASP.NET application. This application has a WCF operation that does some processing. Currently, I am to do my processing correctly from within my WCF operation. However, I would like to do this asynchronously. In an error to attempt this asynchronously, I tried running Server.Execute in the DoWork event handler of a BackgroundWorker. Unfortunately, this throws an error that says "object reference not set to an instance of an object" The HttpContext element is not null. I checked that. It is some property nested in the HttpContext object that appears to be null. However, I have not been able to identify why this won't work. It happens as soon as I move the processing to the BackgroundWorker thread. My question is, how can I asynchronously execute the Server.Execute method? Thank you,

    Read the article

  • Silverlight 3 - HeaderedItemsControl ControlTemplate

    - by user208662
    Hello, I am trying to create a HeaderedItemsControl where the headers are frozen. In an attempt to accomplish this, I have been trying to build on the default control template generated by Blend. I am using this default template in the following manner: <controls:HeaderedItemsControl x:Name="informationItemsControl"> <controls:HeaderedItemsControl.Template> <ControlTemplate> <Grid x:Name="Root"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <ContentControl x:Name="HeaderContent" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/> <ItemsPresenter x:Name="Items" Grid.Row="1"/> </Grid> </ControlTemplate> </controls:HeaderedItemsControl.Template> ... </controls:HeaderedItemsControl> Oddly, when I use the default template, a blank screen appears in my application. A JavaScript error bubbles up that says: Error: Unhandled Error in Silverlight Application Code: 2012 Category: ParserError Message: Unknown attribute Content on element ContentControl. File: Line: 6 Position: 107 Source File: http://localhost:2995/ Line: 60 I noticed that this error appears as long as either Content="{TemplateBinding Header}" or ContentTemplate="{TemplateBinding HeaderTemplate}" exist in the ControlTemplate. If I remove both of those, the items appear just fine (but no header). I tried with a simple header that was just a TextBlock and I still received the error. What am I doing wrong? How do I get the Header to display within the ControlTemplate?

    Read the article

  • Silverlight - Get the ItemsControl of a DataTemplate

    - by user208662
    Hello, I have a Silverlight application that is using a DataGrid. Inside of that DataGrid I have a DataTemplate that is defined like the following: <Grid x:Name="myGrid" Tag="{Binding}" Loaded="myGrid_Loaded"> <ItemsControl ItemsSource="{Binding MyItems}" Tag="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Width="138"> <TextBlock Text="{Binding Type}" /> <TextBox x:Name="myTextBox" TextChanged="myTextBox_TextChanged" /> </StackPanel> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> When a user enters text into the TextBox, I have an event (myTextBox_TextChanged) that must be fired at this point. When that event gets fired, I would like to get the ItemsControl element that is the container for this TextBox. How do I get that ItemsControl from my event handler? Please note: Because the ItemsControl is in the DataTemplate of DataGrid, I don't believe I can just add an x:Name and reference it from my code-behind. Or is there a way to do that? Thank you!

    Read the article

  • WCF and ASP.NET - Server.Execute throwing object reference not set to an instance of an object

    - by user208662
    Hello, I have an ASP.NET page that calls to a WCF service. This WCF service uses a BackgroundWorker to asynchronously create an ASP.NET page on my server. Oddly, when I execute the WCF Service [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] public void PostRequest(string comments) { // Do stuff // If everything went o.k. asynchronously render a page on the server. I do not want to // block the caller while this is occurring. BackgroundWorker myWorker = new BackgroundWorker(); myWorker.DoWork += new DoWorkEventHandler(myWorker_DoWork); myWorker.RunWorkerAsync(HttpContext.Current); } private void myWorker_DoWork(object sender, DoWorkEventArgs e) { // Set the current context so we can render the page via Server.Execute HttpContext context = (HttpContext)(e.Argument); HttpContext.Current = context; // Retrieve the url to the page string applicationPath = context.Request.ApplicationPath; string sourceUrl = applicationPath + "/log.aspx"; string targetDirectory = currentContext.Server.MapPath("/logs/"); // Execute the other page and load its contents using (StringWriter stringWriter = new StringWriter()) { // Write the contents out to the target url // NOTE: THIS IS WHERE MY ERROR OCCURS currentContext.Server.Execute(sourceUrl, stringWriter); // Prepare to write out the result of the log targetPath = targetDirectory + "/" + DateTime.Now.ToShortDateString() + ".aspx"; using (StreamWriter streamWriter = new StreamWriter(targetPath, false)) { // Write out the content to the file sb.Append(stringWriter.ToString()); streamWriter.Write(sb.ToString()); } } } Oddly, when the currentContext.Server.Execute method is executed, it throws an "object reference not set to an instance of an object" error. The reason this is so strange is because I can look at the currentContext properties in the watch window. In addition, Server is not null. Because of this, I have no idea where this error is coming from. Can someone point me in the correct direction of what the cause of this could be? Thank you!

    Read the article

  • SQL Server 2008 - Conditional Range

    - by user208662
    Hello, I have a database that has two tables. These two tables are defined as: Movie ----- ID (int) Title (nvchar) MovieReview ----------- ID (int) MovieID (int) StoryRating (decimal) HumorRating (decimal) ActingRating (decimal) I have a stored procedure that allows the user to query movies based on other user's reviews. Currently, I have a temporary table that is populated with the following query: SELECT m.*, (SELECT COUNT(ID) FROM MovieReivew r WHERE r.MovieID=m.ID) as 'TotalReviews', (SELECT AVG((r.StoryRating + r.HumorRating + r.ActingRating) / 3) FROM MovieReview r WHERE r.MovieID=m.ID) as 'AverageRating' FROM Movie m In a later query in my procedure, I basically want to say: SELECT * FROM MyTempTable t WHERE t.AverageRating >= @lowestRating AND t.AverageRating <= @highestRating My problem is, sometimes AverageRating is zero. Because of this, I'm not sure what to do. How do I handle this scenario in SQL?

    Read the article

  • Error Serializing a CLR object for use in a WCF service

    - by user208662
    Hello, I have written a custom exception object. The reason for this is I want to track additional information when an error occurs. My CLR object is defined as follows: public class MyException : Exception { public override string StackTrace { get { return base.StackTrace; } } private readonly string stackTrace; public override string Message { get { return base.Message; } } private readonly string message; public string Element { get { return element; } } private readonly string element; public string ErrorType { get { return errorType; } } private readonly string errorType; public string Misc { get { return misc; } } private readonly string misc; #endregion Properties #region Constructors public MyException() {} public MyException(string message) : base(message) { } public MyException(string message, Exception inner) : base(message, inner) { } public MyException(string message, string stackTrace) : base() { this.message = message; this.stackTrace = stackTrace; } public MyException(string message, string stackTrace, string element, string errorType, string misc) : base() { this.message = message; this.stackTrace = stackTrace; this.element = element; this.errorType = errorType; this.misc = misc; } protected MyException(SerializationInfo info, StreamingContext context) : base(info, context) { element = info.GetString("element"); errorType = info.GetString("errorType"); misc = info.GetString("misc"); } public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("element", element); info.AddValue("errorType", errorType); info.AddValue("misc", misc); } } I have created a copy of this custom xception in a WP7 application. The only difference is, I do not have the GetObjectData method defined or the constructor with SerializationInfo defined. If I run the application as is, I receive an error that says: Type 'My.MyException' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. If I add the DataContract / DataMember attributes to the class and its appropriate members on the server-side, I receive an error that says: Type cannot be ISerializable and have DataContractAttribute attribute. How do I serialize MyException so that I can pass an instance of it to my WCF service. Please note, I want to use my service from an Android app. Because of this, I don't want to do anything too Microsoft centric. That was my fear with DataContract / DataMember stuff. Thank you so much for your help!

    Read the article

  • SQL Server 2008 - Search Query

    - by user208662
    Hello, I am not a SQL Expert. I’m trying to elegantly solve a query problem that others have had to have had. Surprisingly, Google is not returning anything that is helping. Basically, my application has a “search” box. This search field will allow a user to search for customers in the system. I have a table called “Customer” in my SQL Server 2008 database. This table is defined as follows: Customer UserName (nvarchar) FirstName (nvarchar) LastName (nvarchar) As you can imagine, my users will enter queries of varying cases and probably mis-spell the customer’s names regularly. How do I query my customer table and return the 25 results that are closest to their query? I have no idea how to do this ranking and consider the three fields listed in my table. Thank you!

    Read the article

  • WCF - Contract Name could not be found in the list of contracts

    - by user208662
    Hello, I am relatively new to WCF. However, I need to create a service that exposes data to both Silverlight and AJAX client applications. In an attempt to accomplish this, I have created the following service to serve as a proof of concept: [ServiceContract(Namespace="urn:MyCompany.MyProject.Services")] public interface IJsonService { [OperationContract] [WebInvoke(Method = "GET", RequestFormat=WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] List<String> JsonFindNames(); } [ServiceContract(Namespace="urn:MyCompany.MyProject.Services")] public interface IWsService { [OperationContract(Name="FindNames")] List<String> WsFindNames(); } [ServiceBehavior(Name="myService", Namespace="urn:MyCompany.MyProject.Services")] public class myService : IJsonService, IWsService { public List<String> JsonFindNames() { return FindNames(); } public List<String> WsFindNames() { return FindNames(name); } public List<string> FindNames() { List<string> names = List<string>(); names.Add("Alan"); names.Add("Bill"); return results; } } When I try to access this service, I receive the following error: The contract name 'myService' could not be found in the list of contracts implemented by the service 'myService'. What is the cause of this? How do I fix this? Thank you

    Read the article

  • How do I return clean JSON from a WCF Service?

    - by user208662
    I am trying to return some JSON from a WCF service. This service simply returns some content from my database. I can get the data. However, I am concerned about the format of my JSON. Currently, the JSON that gets returned is formatted like this: {"d":"[{\"Age\":35,\"FirstName\":\"Peyton\",\"LastName\":\"Manning\"},{\"Age\":31,\"FirstName\":\"Drew\",\"LastName\":\"Brees\"},{\"Age\":29,\"FirstName\":\"Tony\",\"LastName\":\"Romo\"}]"} In reality, I would like my JSON to be formatted as cleanly as possible. I believe (I may be incorrect), that the same collection of results, represented in clean JSON, should look like so: [{"Age":35,"FirstName":"Peyton","LastName":"Manning"},{"Age":31,"FirstName":"Drew","LastName":"Brees"},{"Age":29,"FirstName":"Tony","LastName":"Romo"}] I have no idea where the “d” is coming from. I also have no clue why the escape characters are being inserted. My entity looks like the following: [DataContract] public class Person { [DataMember] public string FirstName { get; set; } [DataMember] public string LastName { get; set; } [DataMember] public int Age { get; set; } public Person(string firstName, string lastName, int age) { this.FirstName = firstName; this.LastName = lastName; this.Age = age; } } The service that is responsible for returning the content is defined as: [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class TestService { [OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json)] public string GetResults() { List<Person> results = new List<Person>(); results.Add(new Person("Peyton", "Manning", 35)); results.Add(new Person("Drew", "Brees", 31)); results.Add(new Person("Tony", "Romo", 29)); // Serialize the results as JSON DataContractJsonSerializer serializer = new DataContractJsonSerializer(results.GetType()); MemoryStream memoryStream = new MemoryStream(); serializer.WriteObject(memoryStream, results); // Return the results serialized as JSON string json = Encoding.Default.GetString(memoryStream.ToArray()); return json; } } How do I return “clean” JSON from a WCF service? Thank you!

    Read the article

  • JavaScript - Detect HTML

    - by user208662
    Hello, I have an HTML textarea element. I want to prevent a user from entering any HTML tags in this area. How do I detect if a user has entered any HTML a textarea with JavaScript? Thank you

    Read the article

  • C# and WCF + Getting the location of execution

    - by user208662
    Hello, I have a WCF service that is responsible for writing a log file. I would like to write a log file relative to the location of my WCF service. This service does NOT have an HttpContext available. Because of this, I cannot use HttpContext.Current.Server.MapPath. How can I get the location of where my WCF service is running so that I can create a log file? Thank you

    Read the article

  • JavaScript and ASP.NET - Cookies with Key / Value Pairs

    - by user208662
    Hello, This question mixes client-side scripting with server-side parsing. In some cases, I'm writing a cookie to the user's browser using the document.cookie property. In other cases, I'm writing the same cookie to the user's browser through the ASP.NET Response object. When I'm writing the HttpCookie on the server-side, I am using the Values collection (http://msdn.microsoft.com/en-US/library/system.web.httpcookie.values%28v=VS.80%29.aspx) to store key/value pairs in the cookie. I would also like to be able to write key-value pairs to the cookie through JavaScript. How do I create cookies with Key/Value pairs via JavaScript that ASP.NET can parse? Thank you!

    Read the article

  • SQL Server 2008 - Full Text Query

    - by user208662
    Hello, I have two tables in a SQL Server 2008 database in my company. The first table represents the products that my company sells. The second table contains the product manufacturer’s details. These tables are defined as follows: Product ------- ID Name ManufacturerID Description Manufacturer ------------ ID Name As you can imagine, I want to make this as easy as possible for our customers to query this data. However, I’m having problems writing a forgiving, yet powerful search query. For instance, I’m anticipating people to search based on phonetical spellings. Because of this, the data may not match the exact data in my database. In addition, I think some individuals will search by manufacturer’s name first, but I want the matching product names to appear first. Based on these requirements, I’m currently working on the following query: select p.Name as 'ProductName', m.Name as 'Manufacturer', r.Rank as 'Rank' from Product p inner join Manufacturer m on p.ManufacturerID=m.ID inner join CONTAINSTABLE(Product, Name, @searchQuery) as r Oddly, this query is throwing an error. However, I have no idea why. Squiggles appear to the right of the last parenthesis in management studio. The tool tip says "An expression of non-boolean type specified in a context where a condition is expected". I understand what this statement means. However, I guess I do not know how COntainsTable works. What am I doing wrong? Thank you

    Read the article

  • SQL Server 2000 - Filter by String Length

    - by user208662
    Hello, I have a database on a SQL Server 2000 server. This database has a table called "Person" that has a field call "FullName" that is a VARCHAR(100). I am trying to write a query that will allow me to get all records that have a name. Records that do not have a name have a FullName value of either null or an empty string. How do I get all of the Person records have a FullName? In other words, I want to ignore the records that do not have a FullName. Currently I am trying the following: SELECT * FROM Person p WHERE p.FullName IS NOT NULL AND LEN(p.FullName) > 0 Thank you

    Read the article

  • JQuery - Element Selection

    - by user208662
    Hello, I'm relatively new to JQuery. I'm trying to understand how to select a child element. Currently, I have some HTML that is defined as follows: <div id="elem1"> <div class="display">Student 1</div> </div> <div id="elem2"> <div class="display">Student 2</div> </div> <div id="elem3"> <div class="display">Student 3</div> </div> When a user clicks a link, one of the elements (elem1, elem2, or elem3) is going to be passed to a function that is defined as follows: function getNodeDisplay(node) { // NOTE: This does not work as desired return $(node).(#".display").html(); } Unfortunately, this approach does not work. How do I get the HTML associated with an element that has a specific class or a given element? Thank you for your help!

    Read the article

  • JQuery - Iterate through SELECT options

    - by user208662
    Hello, I have a SELECT element in HTML. This element represents a drop down list. I'm trying to understand how to iterate through the options in the SELECT element via JQuery. How do I use JQuery to display the value and text of each option in a SELECT element? I just want to display them in an alert() box. Thank you!

    Read the article

  • Silverlight 3 + DataGrid.SelectedItems Question

    - by user208662
    Hello, I am binding a collection of MyItem class instances to a DataGrid. The MyItem class has a property called "IsSelected". This property can get changed programmatically. How do I propogate that change back to the UI such that if this value is true, the row associated with MyItem is highlighted (selected) and if it is false, the row associated with MyItem is not highlighted? Thank you,

    Read the article

  • C# + String Formatting

    - by user208662
    Hello, I feel like I'm trying to do something simple but I am not getting the result I want. I want to display a basic number, that will always be positive. I do not want any leading zeros but I want thousands separators. For instance, for the following inputs, I want the following outputs: 3 -> 3 30 -> 30 300 -> 300 3000 -> 3,000 30000 -> 30,000 300000 -> 300,000 Currently, in an attempt to do this, I'm using the following formatting code: string text = "*Based on " + String.Format("{0:0,0}", total) + " entries"; Currently, the output looks like this: 3 -> 03 3000 -> 3,000 You can see how a leading "0" is added when the thousands separator is not necessary. How do I properly format my numbers? Thank you

    Read the article

1