TerryDev
TerryDev
CC#
Created by TerryDev on 1/30/2024 in #help
MudBlazor Generic Server Side Table Issues
Hello all, I am attempting to make a more "generic" MudTable on Blazor Server, as I use them frequently across my application. I made one for "client side" data, which works just fine. I am now trying to make one for server side data. My code somewhat works, as the data loads perfectly fine and changing the records per page also works perfectly fine. My issue is with changing the page on my paginator. I'm not sure what exactly is going on, but hooking up a debugger to my PageChanged function on my Paging.razor component shows that the function gets called twice, back to back. One to change the page to the one I clicked on, and another which sets selectedPage back to 1. I cannot figure out why it's getting called twice, and why it keeps getting reset back to one every single time. Any help is very much appreciated. Here's my code: https://gist.github.com/msuddaby/6ed764807ae386060a3b0c662c34a941
4 replies
CC#
Created by TerryDev on 12/11/2022 in #help
✅ Need some help converting PHP code to CS
Hey, I think I wrote this right but I'm getting different results. Perhaps someone knows what I did wrong here? I'm trying to convert a PHP function to a C# function. Here is what I wrote in C#. The original PHP snippets are the comments above.
string tobase64str(string input, int count)
{
string output = "";
int i = 0;
string itoa64 = _password_itoa64();
do
{
//string value = ord($input[$i++]);
var value = input[i++];
//$output.= $itoa64[$value & 0x3f];
output += itoa64[value & 0x3f];
//if ($i < $count) {
if (i < count)
{
//$value |= ord($input[$i]) << 8;
value = ((char)(value | input[i] << 8));
}
//$output.= $itoa64[($value >> 6) & 0x3f];
output += itoa64[(value >> 6) & 0x3f];
//if ($i++ >= $count) {
if (i++ >= count)
{
break;
}
//if ($i < $count) {
if (i < count)
{
//$value |= ord($input[$i]) << 16;
value = (char)(value | input[i] << 16);
}
//$output.= $itoa64[($value >> 12) & 0x3f];
output += itoa64[(value >> 12) & 0x3f];
//if ($i++ >= $count) {
if (i++ >= count)
{
break;
}
//$output.= $itoa64[($value >> 18) & 0x3f];
output += itoa64[(value >> 18) & 0x3f];
} while (i < count);

return output;
}

string _password_itoa64()
{
return "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
}
string tobase64str(string input, int count)
{
string output = "";
int i = 0;
string itoa64 = _password_itoa64();
do
{
//string value = ord($input[$i++]);
var value = input[i++];
//$output.= $itoa64[$value & 0x3f];
output += itoa64[value & 0x3f];
//if ($i < $count) {
if (i < count)
{
//$value |= ord($input[$i]) << 8;
value = ((char)(value | input[i] << 8));
}
//$output.= $itoa64[($value >> 6) & 0x3f];
output += itoa64[(value >> 6) & 0x3f];
//if ($i++ >= $count) {
if (i++ >= count)
{
break;
}
//if ($i < $count) {
if (i < count)
{
//$value |= ord($input[$i]) << 16;
value = (char)(value | input[i] << 16);
}
//$output.= $itoa64[($value >> 12) & 0x3f];
output += itoa64[(value >> 12) & 0x3f];
//if ($i++ >= $count) {
if (i++ >= count)
{
break;
}
//$output.= $itoa64[($value >> 18) & 0x3f];
output += itoa64[(value >> 18) & 0x3f];
} while (i < count);

return output;
}

string _password_itoa64()
{
return "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
}
Upon running this, I do not get the expected result of: VrOlH8EFHZWQeyrP2on5MR7Q8QMC08ZnHfLv8UE54ZwL7CIJ6vKhT3EpdYriab.oA/yv9wP/yyWUHQC9.18y0$S$D Instead, I get: /..l1..F1..Q0..P...5...Q0..C0..n1..v0..50..L/..J...h1..p/..i0..o...v1../0..U1..9...y0
35 replies