Access Page Elements by Item Names - xamarin.forms

In windows forms i access the all elements on page by these codes.(by names)
for (int ix = 1; ix < 31; ix++)
{
string name = string.Format("{0}{1}", "lbl", ix);
var nesne = this.Controls[name] as Label;
nesne.BackgroundColor = Color.FromHex("54C642");
}
How can i do on Xamarin?

use FindByName
var element = FindByName("myControlName");

If you're developing Xamarin.Forms , use x:Name .
Xaml
<object x:Name="XAMLNameValue".../>
Code behind
XAMLNameValue.BackgroundColor = Color.White;

Related

Add Columns Dynamically at specific index to existing RadGrid

I have to add custom column runtime on specific location to exiting telerik grid.
string[] customColumns = ds.Tables[2].Rows[0]["CustomColumns"].ToString().Split(',');
int startIndex = 7;
for (int i = 0; i < customColumns.Length; i++)
{
GridBoundColumn NewColumn = new GridBoundColumn();
tableGrid.MasterTableView.Columns.AddAt(startIndex, NewColumn);
NewColumn.HeaderText = customColumns[i].Replace("[", "").Replace("]", "");
NewColumn.DataField = customColumns[i].Replace("[", "").Replace("]", "");
NewColumn.Visible = true;
NewColumn.FilterControlWidth = Unit.Percentage(70);
NewColumn.HeaderStyle.CssClass = "setHeader";
NewColumn.HeaderStyle.Width = 130;
NewColumn.AllowFiltering = true;
NewColumn.OrderIndex = startIndex;
startIndex++;
}
Using this block of code column added successfully at given location but when I used existing grid filter functionality then position of column is changed and even I can't see value in column.
You will need to define an OrderIndex for the columns, and when adding a new one to the grid, you will know which OrderIndex to use. Check out the Reordering columns programmatically article for your reference.

Disable the NavGrid buttons in JQGrid when grid is empty

I want to Disable the NavGrid buttons in JQGrid when grid is empty.
I am using the following code, but buttons are not getting disabled.
var rowCount = jQuery('#gridID').jqGrid('getGridParam', 'reccount');
if (rowCount == 0) {
$("view_" + "#gridID").addClass('ui-state-disabled');
$("refresh_" + "#gridID").addClass('ui-state-disabled');
}
Any help on this is highly appreciated.
I have resolved the above issue. See my below code:
var rowCount = jQuery('#gridID').jqGrid('getGridParam', 'reccount');
if (rowCount == 0) {
var grid = $("#gridID"),
gid = $.jgrid.jqID(grid[0].id);
var $viewBtn = $('#view_' + gid);
$viewBtn.addClass("ui-state-disabled");
var $refreshBtn = $('#refresh_' + gid);
$refreshBtn.addClass("ui-state-disabled");
}

DevExpress ASPxComboBox Items Color Change from Code Behind

I have a ASPxComboBox for which I'm binding data based on 2 conditions.
Now,I need to show Color for items in combobox based on condition.
My Code :
var dataMainBranchUsers = (from xx in VDC.SURVEY_USER_DETAILS
where xx.BRANCH_ID == 1 && (xx.USER_LEVEL == 2 || xx.USER_LEVEL == 5)
select new
{
xx.USER_NAME,
xx.USER_ID,
xx.USER_LEVEL
}).ToList();
DataTable dtMainBranchUsers = LINQToDataTable(dataMainBranchUsers);
for (int i = 0; i < dtMainBranchUsers.Rows.Count; i++)
{
string strlevel = dtMainBranchUsers.Rows[i]["USER_LEVEL"].ToString();
string struser = dtMainBranchUsers.Rows[i]["USER_NAME"].ToString();
if (strlevel == "2")
{
dtMainBranchUsers.Rows[i]["USER_NAME"] = struser + " - Admin";
}
else
{
dtMainBranchUsers.Rows[i]["USER_NAME"] = struser + " - Survey User";
}
}
Cmb_UserName.TextField = "USER_NAME";
Cmb_UserName.ValueField = "USER_ID";
Cmb_UserName.DataSource = dtMainBranchUsers;
Cmb_UserName.DataBind();
Now, I need to differentiate based on USER_LEVEL and show colors.
Is this possible?
From DevExpress
I'm afraid, the ASPxListBox (which is the part of the ASPxComboBox) doesn't allow to set specific color for each item.
I suggest you to use the ASPxDropDownEdit. This control allows to put anything in its DropDownWindowTemplateContainer.
For example, you can put the ASPxGridView and set color for each row using the HtmlRowPrepared event handler.
See here.

How can I find the last labelId in AX2009?

I'd like to insert all Labels from a labelModuleId in an AX2009 table.
I have this job, that does nearly everything I need. But I have to enter the max Id (toLabel = 1000):
static void OcShowAllLabel(Args _args)
{
xInfo xinfo;
LanguageId currentLanguageId;
LabelModuleId labelModuleId = 'OCM'; // hier evt eine Eingabe durch Benutzer zur Auswahl
LabelIdNum frLabel;
LabelIdNum toLabel = 1000;
LabelId labelId;
OcShowAllLabels_RS tab;
Label blub = new Label();
str label;
;
xInfo = new xInfo();
currentLanguageId = xInfo.language();
delete_from tab
where tab.LanguageId == currentLanguageId
&& tab.LabelModuleId == labelModuleId;
for (frLabel = 1; frLabel <= toLabel; frLabel++)
{
labelId = strfmt('#%1%2', labelModuleId, frLabel);
label = SysLabel::labelId2String(labelId, currentLanguageId);
if (labelId != label)
{
tab.initValue();
tab.LabelId = labelId;
tab.Label = label;
tab.LanguageId = currentLanguageId;
tab.LabelModuleId = labelModuleId;
tab.insert();
}
}
Info('done');
}
If this is a one-time job, you can just stop the AOS and open the label file in notepad. It's in your application folder called axXXXen-us.ald, where XXX is your label file name and en-us is your language.
Look at classes\Tutorial_ThreadWork\doTheWork to see where they use a while(sLabel) instead of a for loop like you have.
container doTheWork(Thread t,LabelType searchFor)
{
container retVal;
SysLabel sysLabel = new SysLabel(LanguageTable::defaultLanguage());
str slabel;
;
slabel = sysLabel.searchFirst(searchFor);
while (slabel)
{
retVal += sLabel;
slabel = sysLabel.searchNext();
}
return retVal;
}
Since the label file is a text file, it would make sense that you can't just select the last one, but you have to iterate through the file. AX caches the labels however, but I don't believe you can just readily access the label cache as far as I know.
Lastly, hopefully you won't try this, but don't try to just read in the label text file, because AX sometimes has labels that it hasn't flushed to that file from the cache. I think Label::Flush(...) will flush them, but I'm not sure.
Here is another option I suppose. You can insert a label to get the next label number and then just immediately delete it:
static void Job32(Args _args)
{
SysLabel sysLabel = new SysLabel(LanguageTable::defaultLanguage());
SysLabelEdit sysLabelEdit = new SysLabeLEdit();
LabelId labelid;
;
labelId = syslabel.insert('alextest', '', 'OCM');
info(strfmt("%1", labelId));
sysLabelEdit.labelDelete(labelId, false);
}
It does seem to consume the number from the number sequence though. You could just do a Label::Flush(...) and then check the text file via code. Look at Classes\SysLabel* to see some of how the system deals with labels. It doesn't look very simple by any means.
Here is another option that might work for you. This will identify missing labels too. Change 'en-us' to your language. This is a "dirty" alternative I suppose. You might need to add something to say "if we find 5 labels in a row where they're like '#OCM'".
for (i=1; i<999; i++)
{
labelId = strfmt("#%1%2", 'OCM', i);
s = SysLabel::labelId2String(labelId, 'en-us');
if (s like '#OCM*')
{
info (strfmt("%1: Last is %2", i, s));
break;
}
info(strfmt("%1: %2", i, s));
}

CKEditor to Send Emails with ASP.NET [vb] - Issues with Special Characters

I have a standard HTML page with an CKEditor on it wrapped in a form.
The form submits (POSTS) to Send_Emails.aspx
Send_Emails.aspx reads the content of the FCKEditor into a variable
Dim html As String = Request.Form("ck_content")
Then it sends an email.
Problem
Characters such as:
 -> this seems to show as a special character for blank spaces/carriage returns
’ -> this seems to show as apostrophe's
Can you reccomend some methods to cleanze my post data of these non-standard characters?
Thanks
I figured out how to strip unwanted characters by using this function:
function removeMSWordChars(str) {
var myReplacements = new Array();
var myCode, intReplacement;
myReplacements[8216] = 39;
myReplacements[8217] = 39;
myReplacements[8220] = 34;
myReplacements[8221] = 34;
myReplacements[8212] = 45;
for(c=0; c<str.length; c++) {
var myCode = str.charCodeAt(c);
if(myReplacements[myCode] != undefined) {
intReplacement = myReplacements[myCode];
str = str.substr(0,c) + String.fromCharCode(intReplacement) + str.substr(c+1);
}
}
return str;
}

Resources