I would like to show desktop view when user uses Ipad.
I use DisplayModeProvide, but sometimes Elmah keep this error:
System.NullReferenceException: in System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath
This is my code:
if (DisplayModeProvider.Instance != null)
if (DisplayModeProvider.Instance.Modes != null)
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf
("iPad", StringComparison.OrdinalIgnoreCase) >= 0)
});
Can someone help me?
We had the same issue, try checking for a null UserAgent
if (DisplayModeProvider.Instance != null)
if (DisplayModeProvider.Instance.Modes != null)
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("")
{
ContextCondition = (context => context.Request.UserAgent != null && context.GetOverriddenUserAgent().IndexOf
("iPad", StringComparison.OrdinalIgnoreCase) >= 0)
});
Related
At this point, I'm spinning my wheels, but going nowhere and could use some help. I have an array/List of weekdays that I want to disable on my calendar using the enabledPredicateDay function. for example ['sunday', 'monday', 'tuesday'].
return TableCalendar(
calendarBuilders: CalendarBuilders(dowBuilder: (context, day) {
if (day.weekday == DateTime.sunday) {
final text = DateFormat.E().format(day);
return Center(
child: Text(
text,
style: TextStyle(color: Colors.red),
),
);
}
}),
firstDay: kFirstDay,
lastDay: kLastDay,
focusedDay: _focusedDay,
calendarFormat: _calendarFormat,
enabledDayPredicate: (date) {
// this is where we disable any days that the user is not available OR is booked up
var disabledDays = "";
unavailableDays.asMap().forEach((index, value) {
if (index == 0) {
disabledDays = disabledDays + "date.weekday != DateTime.$value";
} else {
disabledDays = disabledDays + " && date.weekday != DateTime.$value";
}
});
date.weekday != disabledDays; // here I'm trying to get some sort of boolean back.
return date.weekday != disabledDays;
}
The problem I'm running into is that I can either only return one day programmatically, let's say in a 'for in' loop, or I need to hardcode it. This is because the return value needs to be a boolean.
I tried combining everything into a string and then converting it to a method so that each day I need disabled can be the return statement like this:
return date.weekday != DateTime.$value && date.weekday != DateTime.$value && date.weekday != DateTime.$value
Everything works fine if I hardcode it like this:
return date.weekday != DateTime.sunday && date.weekday != DateTime.monday && date.weekday != DateTime.tuesday
But I haven't been able to get to this point because I'm getting a string back, but I need a bool.
How do I return multiple days to this particular function?
I figured it out...seems very hacky and maybe this can be improved. What I did here was instantiated a variable for each day. And then, as I go through the weekdays to check which is unavailable with conditional statements, I assign the weekday to the variable if and only if it's unavailable.
var unavailableDay1;
var unavailableDay2;
var unavailableDay3;
var unavailableDay4;
var unavailableDay5;
var unavailableDay6;
var unavailableDay7;
for (var day in daysOfWeek) {
// print(widget.data[day]);
if (widget.data[day] == null) {
unavailableDays.add(day);
}
}
for (var day in unavailableDays) {
if (day == "monday") {
unavailableDay1 = 1;
} else if (day == "tuesday") {
unavailableDay2 = 2;
} else if (day == "wednesday") {
unavailableDay3 = 3;
} else if (day == "thursday") {
unavailableDay4 = 4;
} else if (day == "friday") {
unavailableDay5 = 5;
} else if (day == "saturday") {
unavailableDay6 = 6;
} else if (day == "sunday") {
unavailableDay7 = 7;
}
}
Finally, I check if each of the 7 days has a value, if not null is returned. Thus, it gives me back only days that are enabled! I hope this helps someone! Please help me improve this!
enabledDayPredicate: (date) {
// this is where we disable any days that the user is not available OR is booked up
return date.weekday != unavailableDay1 &&
date.weekday != unavailableDay2 &&
date.weekday != unavailableDay3 &&
date.weekday != unavailableDay4 &&
date.weekday != unavailableDay5 &&
date.weekday != unavailableDay6 &&
date.weekday != unavailableDay7;
},
Making a winforms application and I want the name of the table in my SQL query to be equal to a variable I have called TreeCodeName. This is my code:
private void button1_Click(object sender, EventArgs e)
{
string TreeNodeName = treeView1.SelectedNode.Name.ToString();
if ((TreeNodeName == "BOOKS") || (TreeNodeName == "CARDS") || (TreeNodeName == "COMPUTERS") || (TreeNodeName == "CONSOLES") || (TreeNodeName == "DEVICES") || (TreeNodeName == "DONORS") || (TreeNodeName == "MAGAZINES") || (TreeNodeName == "MOTHERBOARDS") || (TreeNodeName == "OTHERS") || (TreeNodeName == "PARTS") || (TreeNodeName == "PERIPHERALS") || (TreeNodeName == "POWER_SUPPLY") || (TreeNodeName == "PROCESSORS") || (TreeNodeName == "RAMS") || (TreeNodeName == "SOFTWARE") || (TreeNodeName == "STORAGE") || (TreeNodeName == "TERMINALS"))
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "select * From Table Where Title = #Title";
command.Parameters.AddWithValue("#Title", TreeNodeName);
command.CommandText = query;
OleDbDataAdapter da = new OleDbDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
}
Whenever I try to test this, I run into an error that says there was a syntax error on FROM. Any way to salvage this?
I'm working with ADF BC and I have several inputTexts.
Let's say I have the folowing scenario:
Step 1: inserting 1, 2, 3 in three different inputTexts (it1, it2 and it3, all three with autoSubmit == true).
Step 2: Click a button who calls the following method:
public String aplicarFiltro() {
Object it1param = null, it2param = null, it3param = null, sos1param = null;
Parametros_IndicadoresLoadAll pila = Parametros_IndicadoresLoadAll.getInstance();
pila.clear();
if(it1.getValue() == null || it1.getValue().toString().isEmpty()) {
it1param = "";
} else {
it1param = it1.getValue();
if(it2.getValue() == null || it2.getValue().toString().isEmpty()) {
it2param = "";
} else {
it2param = it2.getValue();
if(it3.getValue() == null || it3.getValue().toString().isEmpty()) {
it3param = "";
} else {
it3param = it3.getValue();
}
}
}
if(sos1.getValue() != null) {
sos1param = sos1.getValue();
}
pila.init(it1param, it2param, it3param, sos1param);
if (it1.getValue() == null || it1.getValue().toString().isEmpty()) {
showPopup(p1, true);
/* } else if (sos3.getValue() == null) {
showPopup(p2, true); */
}
return null;
}
Step 3: I erase the values from it2 and it3, I click the button again and call the same method. However, the value from it2 and it3 stays the same.
Why does this happen and how can I fix it?
Try to re-think your approach: instead of doing the business in backing beans, try to use BC layer. So you can move the method
public String aplicarFiltro() {..} into Application Module Impl.
There, programatically get a reference to your VO's current Row and read the attribute's values.
First, test your scenario (your method) from BC Tester. Then, you can expose the method through bindings, and call it from backing beans.
ALso, I would expose the RowImpl class for your VO and put some debug info into setIt1(), setIt2(), setIt3() attributes, to see how the change.
Remember, is always far more simple to manage your business on BC layer than managed beans. Stay away from JSF life cycle.
Don't know if more things are wrong. But you're only setting "i2param" to something other than null if i1 has a value and "i3param" to something other then null if i1 and i2 has a value.
So start with the following. Change this:
if(it1.getValue() == null || it1.getValue().toString().isEmpty()) {
it1param = "";
} else {
it1param = it1.getValue();
if(it2.getValue() == null || it2.getValue().toString().isEmpty()) {
it2param = "";
} else {
it2param = it2.getValue();
if(it3.getValue() == null || it3.getValue().toString().isEmpty()) {
it3param = "";
} else {
it3param = it3.getValue();
}
}
}
to:
if(it1.getValue() == null || it1.getValue().toString().isEmpty()) {
it1param = "";
} else {
it1param = it1.getValue();
}
if(it2.getValue() == null || it2.getValue().toString().isEmpty()) {
it2param = "";
} else {
it2param = it2.getValue();
}
if(it3.getValue() == null || it3.getValue().toString().isEmpty()) {
it3param = "";
} else {
it3param = it3.getValue();
}
I want to change value's based on other values in a repeat. I made a watch but the thing is that if i alter the newValue inside the watch the watch is triggered again.
Is there a way to solve this problem
my watch:
$scope.$watch('objlist', function(newValue, oldValue) {
$scope.counter += 1;
for (var count = 0; count < newValue.length; ++count) {
if (typeof newValue[count] != "undefined" && (typeof oldValue == "undefined" || newValue[count].value1 != oldValue[count].value1)) {
newValue[count].value3 = newValue[count].value1 * newValue[count].value2;
newValue[count].value3 = Number(newValue[count].value3).toFixed(2);
}
if (typeof newValue[count] != "undefined" && (typeof oldValue == "undefined" || newValue[count].value3 != oldValue[count].value3)) {
newValue[count].value1 = newValue[count].value3 / newValue[count].value2;
newValue[count].value1 = Number(newValue[count].value1).toFixed(2);
}
}
}, true);
i have included a plunker to show you what i mean.
plunker
as you can see if you change the value of field 1 or 3 it automaticly adds 2 to the counter and sets both to toFixed(2). This makes it hard to edit the fields.
We use angular 1.2.25
You could use a small trick with a condition.
For instance :
$scope.watchActivated = true;
$scope.$watch('objlist', function(newValue, oldValue) {
if ( $scope.watchActivated ) {
$scope.watchActivated = false;
$scope.counter += 1;
for (var count = 0; count < newValue.length; ++count) {
if (typeof newValue[count] != "undefined" && (typeof oldValue == "undefined" || newValue[count].value1 != oldValue[count].value1) )
{
newValue[count].value3 = newValue[count].value1 * newValue[count].value2;
newValue[count].value3 = Number(newValue[count].value3).toFixed(2);
}
if (typeof newValue[count] != "undefined" && (typeof oldValue == "undefined" || newValue[count].value3 != oldValue[count].value3) )
{
newValue[count].value1 = newValue[count].value3 / newValue[count].value2;
newValue[count].value1 = Number(newValue[count].value1).toFixed(2);
}
}
$scope.watchActivated = true;
}
}, true);
Far from elegant but it should work.
Careful the code might not be good I just did a quick edit.
I have made a validation to prevent data into being inserted to the DB when it's empty but it still enters a blank form to the database?
protected void Button1_Click(object sender, EventArgs e)
{
ProjectTestEntities User_save = new ProjectTestEntities();
User ins = new User();
ins.name = TextBox1.Text;
ins.email = TextBox2.Text;
ins.phone = TextBox3.Text;
ins.gender = RadioButtonList1.SelectedValue;
ins.password = TextBox4.Text;
if (ins.name == null || ins.email == null || ins.gender == null || ins.password == null)
{
Label1.Text = "Incomplete input";
}
else
{
User_save.Users.AddObject(ins);
User_save.SaveChanges();
}
}
Try using string.IsNullOrEmpty()
if (string.IsNullOrEmpty(ins.name == null) ||
string.IsNullOrEmpty(ins.email == null) ||
string.IsNullOrEmpty(ins.gender == null) ||
string.IsNullOrEmpty(ins.password == null))
{
Label1.Text = "Incomplete input";
}
else
{
User_save.Users.AddObject(ins);
User_save.SaveChanges();
}