Challenge the behavior : How to hide dates in RadScheduler using jQuery

Introduction

RadScheduler is a control provided by Telerik that allows you to display and manage appointments and events in various calendar views. It is commonly used in applications where scheduling and time management are important, such as in healthcare systems, project management software, and booking systems.

Some of the key features of RadScheduler include

  • Multiple views: RadScheduler provides various calendar views, such as day, week, month, and timeline views, allowing you to display appointments and events in the most appropriate format.
  • Customizable appearance: You can customize the appearance of the scheduler to match your application’s look and feel, including the colors, fonts, and styles of the various elements.
  • Recurring appointments: RadScheduler allows you to create appointments that recur on a regular basis, such as daily, weekly, or monthly appointments.
  • Drag-and-drop support: You can easily move appointments by dragging and dropping them to a new time or date.
  • Built-in dialogs: RadScheduler includes built-in dialogs for creating, editing, and deleting appointments, making it easy for users to interact with the scheduler.
  • Data binding: RadScheduler can be bound to various data sources, such as databases or web services, allowing you to display and manage data dynamically.

Overall, RadScheduler is a powerful and flexible tool for managing appointments and events in a variety of applications.

How to hide dates in RadScheduler using jQuery

Sometimes developer need to hide the date of Scheduler for fulfill the customer requirement, so below we are talking how to hide dates in RadScheduler using jQuery. This is mainly focus on Weekly view you can change according to your requirement.

CS File

protected void SchedulerTimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
{
        e.TimeSlot.CssClass = "HideDates";
}

ASPX File

function pageLoad() {
      if ($find('<%=rsRoomBooking.ClientID %>').get_selectedView() ==      

                                          Telerik.Web.UI.SchedulerViewType.WeekView) {
            let hideDaysIndexes = new Array();
            var $ = $telerik.$;

           $('.HideDates').each(function (i) {
                  hideDaysIndexes.push($(this).index());
          });

           for (x in hideDaysIndexes) {
                   $($(".rsHorizontalHeaderTable tr:nth-child(1) th",                      
                                $find('<%=rsRoomBooking.ClientID
                              %>').get_element()).get(hideDaysIndexes[x])).find('a').remove();
           }

                $('.rsContentTable tr .HideDates').css("pointer-  
                  events","none");
                hideDaysIndexes = [];
          }
}

CSS File

.HideDates{
       background: #ddd !important;
}

How to hide dates in RadScheduler using jQuery
How to hide dates in RadScheduler using jQuery

Challenge the behavior How to remove dates from the RadScheduler

To remove dates from the RadScheduler, after particular date from RadScheduler you can used the following code. Following example we are remove dates from scheduler a year from today.

Remove dates from the RadScheduler

Remove dates from the RadScheduler
Remove dates from the RadScheduler

Using the Telerik RadScheduler control, you can build powerful ASP.NET applications to allow users to create and manage tasks. RadScheduler displays and edits scheduled appointments that are stored in a separate data source.A variety of data binding options allows you to work with data sources that are as simple or as powerful as you want.

Some of the key features of RadScheduler include

  • Multiple views: RadScheduler provides various calendar views, such as day, week, month, and timeline views, allowing you to display appointments and events in the most appropriate format.
  • Customizable appearance: You can customize the appearance of the scheduler to match your application’s look and feel, including the colors, fonts, and styles of the various elements.
  • Recurring appointments: RadScheduler allows you to create appointments that recur on a regular basis, such as daily, weekly, or monthly appointments.
  • Drag-and-drop support: You can easily move appointments by dragging and dropping them to a new time or date.
  • Built-in dialogs: RadScheduler includes built-in dialogs for creating, editing, and deleting appointments, making it easy for users to interact with the scheduler.
  • Data binding: RadScheduler can be bound to various data sources, such as databases or web services, allowing you to display and manage data dynamically.

Related Article

Quick and Easy Ways to Get Selected Row Count in Telerik RadGrid

Easy Way To Transforming Radio Button Lists into Push Button Lists: A Step-by-Step

Transforming Radio Button Lists into Push Button Lists

Transforming Radio Button Lists into Push Button Lists is different, so it may not be possible to directly convert a radio button into a push button. However, you can achieve a similar effect by using some CSS

Here’s an example of how you can make a radio button list appear like a push button list :

HTML

<asp:RadioButtonList CssClass="radioButtonList" ID="RB1" RepeatDirection="Horizontal">
	<Items>													
              <asp:ListItem Text="1" Value="1"></asp:ListItem>
	      <asp:ListItem Text="2" Value="2"></asp:ListItem>
	     <asp:ListItem Text="3" Value="3"></asp:ListItem>
       </Items>						
</asp:RadioButtonList>

CSS

.radioButtonList input[type="radio"] {
	opacity: 0;
	position: fixed;
	width: 0;
}

.radioButtonList label {
	background-color: #fff;
	padding: .375rem .75rem;
	font-family: sans-serif;
	font-size: 1rem;
	border: 1px solid #ccc !important;
	border-radius: 2px;
}

.d-inline-flex .radioButtonList label {
	margin: 0;
}

.radioButtonList input[type="radio"]:checked + label {
	background-color: #e9ecef;
	border-color: transparent;
}

Out put

Transforming Radio Button Lists into Push Button Lists
Transforming Radio Button Lists into Push Button Lists

The above code will create a label that looks like a push button and will hide the radio button using CSS. When the label is clicked, the corresponding radio button will be selected.

Note that this is just an example and you may need to modify the CSS to match the look and feel of your website.

Transforming Radio Button Lists into Push Button Lists

Error Cannot get the value of a token type ‘Number’ as a string System.Text.Json

Facing errors while coding is inevitable, but it’s how we tackle them that sets us apart. If you’ve encountered the frustrating “Error: Cannot Get the Value of a Token Type” in your C# code, fear not. We’ll delve into this issue and provide actionable solutions to get your code back on track.

Common Causes of the “Cannot Get the Value of a Token Type” Error

Let’s explore some common scenarios where this error may occur:

1. Incomplete or Incorrect Syntax

One of the primary culprits behind this error is incomplete or incorrect syntax. Check your code thoroughly, paying close attention to any missing brackets, semicolons, or incorrect method calls. Even minor syntax errors can lead to significant issues.

2. Incorrect Usage of Tokens

Ensure that you’re using tokens correctly within your code. Tokens serve as placeholders for values and have specific rules for retrieval. Attempting to access the value of a token type that doesn’t support retrieval will result in the “Cannot Get the Value of a Token Type” error.

3. Mismatches in Data Types

Data type mismatches can also trigger this error. Verify that the data types you’re working with align correctly throughout your code. Incompatible data types can prevent the retrieval of token values, leading to errors.

Resolving the “Cannot Get the Value of a Token Type” Error

Now that we’ve identified potential causes, let’s discuss how to resolve this error effectively:

1. Review and Correct Syntax Errors

Start by reviewing your code for any syntax errors. Pay attention to compiler warnings and error messages, as they can often pinpoint the location of syntax issues. Once identified, correct the errors to ensure proper code execution.

2. Verify Token Usage

Double-check the usage of tokens within your code. Ensure that you’re adhering to the correct syntax and guidelines for working with tokens. If necessary, consult the documentation or seek assistance from fellow developers to clarify any uncertainties.

3. Ensure Data Type Consistency

Verify that data types are consistent throughout your code. If you encounter mismatches, adjust variable declarations or conversions accordingly to maintain data type integrity. This will prevent conflicts and facilitate smooth value retrieval.

4. Utilize Debugging Tools

Take advantage of debugging tools provided by your IDE or development environment. Debugging allows you to step through your code, inspect variables, and identify any issues in real-time. Use breakpoints strategically to isolate problematic areas and diagnose the root cause of the error.

5. Test and Iterate

Once you’ve implemented potential solutions, thoroughly test your code to ensure that the error has been resolved. Test different scenarios and edge cases to validate the robustness of your solution. Iterate as needed until you achieve the desired outcome.

Resolve Error Cannot get the value of a token type ‘Number’ as a string System.Text.Json

When Deserialize Json string It return this Exception, Error Cannot get the value of a token type ‘Number’ as a string System.Text.Json resolved this issue used following code sample

public class StringConverter : System.Text.Json.Serialization.JsonConverter<string>
{
	public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions 
                                                     options)
	{

		if (reader.TokenType == JsonTokenType.Number)
		{
			var stringValue = reader.GetInt64();
			return stringValue.ToString();
		}
		else if (reader.TokenType == JsonTokenType.String)
		{
			return reader.GetString();
		}

		throw new System.Text.Json.JsonException();
	}

	public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
	{
		writer.WriteStringValue(value);
	}

}

Class File

[JsonConverter(typeof(StringConverter))]

public string Time { get; set; }

public string RefID { get; set; }

Conclusion

Encountering errors like “Cannot Get the Value of a Token Type” can be frustrating, but with patience and perseverance, they can be overcome. By understanding the underlying causes, reviewing common pitfalls, and implementing effective troubleshooting strategies, you can resolve such errors efficiently. Remember to leverage debugging tools, seek assistance when needed, and test rigorously to ensure the stability of your code. With these approaches in your toolkit, you’ll be well-equipped to tackle any coding challenge that comes your way.

ASP Net WebAPI and SignalR: Easy way Learn

SignalR

SignalR is a library for ASP NET developers to add real-time web functionality to applications. Real-time web functionality is the ability to have server-side code push content to the connected clients as it happens, in real-time.Most developer use ASP Net WebAPI and SignalR for there real time update

ASP.Net WebAPI and SignalR
ASP Net WebAPI and SignalR

Unlocking Real-Time Potential with ASP NET WebAPI

ASP NET WebAPI, a framework designed for building HTTP services, has become a cornerstone in modern web development. Its ability to streamline the creation of RESTful APIs has revolutionized the way data is exchanged between clients and servers. By embracing a straightforward architecture, developers can effortlessly expose their application’s data and functionalities.

Revitalizing Communication Channels with SignalR Integration

SignalR, on the other hand, introduces a layer of real-time functionality to ASP NET applications, enabling seamless bi-directional communication between the server and connected clients. This open-source library simplifies the complexities of handling websockets, long polling, and other real-time communication protocols, making it an ideal companion for enhancing user engagement.

Unveiling the Symbiosis: ASP NET WebAPI and SignalR

1. Streamlined Data Delivery with WebAPI: ASP NET WebAPI excels in delivering data in a concise and structured manner. By embracing RESTful principles, it ensures efficient communication between clients and servers. Developers can harness its capabilities to transmit updates and changes seamlessly, laying the foundation for real-time interactions.

2. Dynamic WebSocket Integration: SignalR seamlessly integrates with ASP NET WebAPI, providing a robust solution for implementing websockets. This dynamic duo facilitates low-latency communication, ensuring that data updates are instantly propagated to connected clients. This real-time synchronization contributes to a responsive and immersive user experience.

3. Building Responsive Interfaces: Leveraging SignalR’s real-time capabilities, developers can create responsive user interfaces that react promptly to changing data. Whether it’s live notifications, collaborative editing, or interactive dashboards, the integration with ASP NET WebAPI allows for the creation of applications that transcend traditional request-response architectures.

Crafting a Real-Time ASP NET WebAPI and SignalR Application

1. Setting Up the Foundation: Begin by establishing the groundwork for your application, setting up ASP NET WebAPI to expose the desired endpoints. Define the data structure and operations that will be the backbone of your real-time features.

2. Integrating SignalR into the Mix: Seamlessly integrate SignalR into your ASP NET WebAPI project to unlock real-time communication capabilities. Leverage SignalR hubs to manage connections and broadcast updates to clients, creating a responsive and engaging user experience.

3. Implementing Real-Time Features: With the foundation in place, start implementing real-time features using SignalR. Whether it’s live chat, notifications, or collaborative editing, the integration with ASP NET WebAPI ensures that your application stays synchronized and responsive.

Get it on NuGet

Install-Package Microsoft.AspNet.SignalR Following article explain when user update the record how to user SignalR and refresh the page

Web API

[HttpGet] 

[Route("getOrderDetails/{OrderStatus?}")]
 public IEnumerable<Orders> GetOrderDetails()
 {
      var _orderDetails= _repo.GetOrderDetails();
      return _orderDetails;
 }

 [HttpPut]

 [Route("updateOrderStatus")]

 public IHttpActionResult UpdateOrderStatus([FromBody] Orders Order)
 {
      var response = new ResponseMassege();
      response = _repo.UpdateOrderStatus(Order);
  
      if (response.ResponseMessage != "Successful")
                 return BadRequest();
      else
          return Ok(response);
 } 

Index Page

  <div class="row" id="divOrder">
     @foreach (var order in Model)
     {
         <div class="col-md-4">
             <div class="col-xs-6 bg-primary">@order.OrderType</div><div class="col-xs-6 bg- 
                   primary">@order.OrderDate</div><br />
             <div class="col-xs-6 bg-success">@order.OrderRefNo</div><div class="col-xs-6 bg-
                  success">@order.OrderThroughDescription</div>
             <div>
                 @{Html.RenderAction("OrderItemDetails", new { OrderRefNo = order.OrderRefNo });}
             </div>
             <br />
             <div><button type="button" class="btn btn-primary" 
                         onclick="UpdatePreparingOrderStatus('@order.OrderRefNo');">Update</button></div>
         </div>
     }
 </div> 

JavaScript

 $(function () {
         var order = $.connection.ordersHub;
         order.client.GetOrderDetails = function () {
             GetOrderDetails();
         };
         $.connection.hub.start();
     });
  
     function GetOrderDetails() {
         $.ajax({
             type: "POST",
             url: '@Url.Action("Index", "Orders")',
             data: {},
             beforeSend: function () {
  
             }, success: function (data) {
                 $("#divOrder").html(data);
             },
             error: function (xhr, errorType, exception) {
                 var errorMessage = exception || xhr.statusText;
             }
         });
     } 

Controller

 public async Task<ActionResult> Index()
         {
             List<Orders> orders = new List<Orders>();
             using (var client = new HttpClient())
             {
                 string requestParams = string.Empty;
  
                 List<KeyValuePair<string, string>> iputParams = new List<KeyValuePair<string, string>>();
                 iputParams.Add(new KeyValuePair<string, string>("OrderStatus", OrderStatus)); 
  
                 requestParams = new FormUrlEncodedContent(iputParams).ReadAsStringAsync().Result;
  
                 client.BaseAddress = new Uri(Baseurl);
                 client.DefaultRequestHeaders.Clear();
                 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                 HttpResponseMessage Res = await client.GetAsync("api/Orders/getOrderDetails?" + requestParams);
                 if (Res.IsSuccessStatusCode)
                 {
                     var ResponseMessage= Res.Content.ReadAsStringAsync().Result;
                     orders = JsonConvert.DeserializeObject<List<Orders>>(ResponseMessage);
                 }
                 return View(orders);
             }
         }
 public async Task<ResponseMassege> UpdatePreparingOrderStatus(string OrderRefNo)
         {
             ResponseMassege responseMassege = new ResponseMassege();
             using (var client = new HttpClient())
             { 
                 client.BaseAddress = new Uri(Baseurl);
                 client.DefaultRequestHeaders.Clear();
  
                 var orderToSend = new Orders()
                 {
                     OrderRefNo = OrderRefNo,
                     OrderStatus = OrderStatus.Preparing
                 };
  
                 var orderContent = new StringContent(JsonConvert.SerializeObject(orderToSend), Encoding.UTF8, 
                                              "application/json");
  
                 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                 HttpResponseMessage Res = await client.PutAsync("api/Orders/UpdateOrderStatus", orderContent);
                 if (Res.IsSuccessStatusCode)
                 {
                     var ResponseMessage = Res.Content.ReadAsStringAsync().Result;
                     responseMassege = JsonConvert.DeserializeObject<ResponseMassege>(ResponseMessage);
                 }
                 OrdersHub.GetOrderDetails();
                 return responseMassege;
             }
         } 

Hub Class

  public class OrdersHub:Hub
 {
         [HubMethodName("getOrderDetails")]
         public static void GetOrderDetails()
         {
              IHubContext context = 
                    GlobalHost.ConnectionManager.GetHubContext<OrdersHub>();
              context.Clients.All.GetOrderDetails();
         }
 }