I have code which displays a confirmation popup.
string message = "Do you want to set activity to Inactive? " ;
message += "The predefined settings will be reset for all the users using this Activity.";
SetToInactiveCheckBox.Attributes["onclick"] = "if($('input[id*=SetToInactiveCheckBox]:checkbox:checked').length > 0 ) return confirm('"+ message +"');";
I want the two lines to be printed in separate lines.
I tried in a following ways
string message = "Do you want to set activity to Inactive? \n" ;
string message = "Do you want to set activity to Inactive? '\r\n'" ;
string message = "Do you want to set activity to Inactive? '<br/>'" ;
How too display the messages in separate lines. I am using IE8.
You can use
\n or \r\n.
If that does not work then use
\\r\\n
You should use
<br />
instead of
'<br />'
This worked for me.
Related
I want to give a title on the message box.
MessageBox.Show("UserName Or Password Does Not Match !!","Error Message");
I have used the above statement to give heading on the message box where the first is shown in the message box and second one is the title of message box.
MessageBox.Show("Are You Login As : "+ dt.Rows[i][1]);
in above statement i want to give message but can not working.
You didn't write a title. If you want to write please add a string after comma
Yours:
MessageBox.Show("Are You Login As : "+ dt.Rows[i][1]);
Mine:
MessageBox.Show("Are You Login As : "+ dt.Rows[i][1], "Title");
I guess you confused between string concatenation and passing two parameters to Message.Show().
Message.Show(string, string), method of expect two strings,
The text to display in the message box.
The text to display in the title bar of the message box.
e.g.
MessageBox.Show("UserName Or Password Does Not Match !!","Error Message");
In your case, MessageBox.Show("Are You Login As : "+ dt.Rows[i][1]);, you are concatenating two string using + operator which only displays text in message body. + dt.Rows[i][1] is not a second parameter passed to Show() method.
You need to pass second parameter with comma,
MessageBox.Show("Are You Login As : "+ dt.Rows[i][1], "Title");
To make it simpler, you can use string interpolation, like
MessageBox.Show($"Are You Login As : {dt.Rows[i][1]}", "Title");
I have a MessageBox that prompts the user if he/she wants to disable everything that they have enabled at once,
DialogResult result = MessageBox.Show("You currently Have : " + Environment.NewLine
+ "// Empty Space" + Environment.NewLine
+ "//Option 1" + Environment.NewLine
+ "//Option 2" + Environment.NewLine
+ "//Option 3" + Environment.NewLine
+ "//Empty Space" + Environment.NewLine
+ "Active For Client 1 Would You Like To Disable All Mods For This Player ?",
"Disable all Client 1's Options",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
}
else if (result == DialogResult.No)
{
}
so when an input has been enabled earlier on in the code it updates the string value in Settings.settings (Visual Studio 2015 Windows Forms Application) with the value enabled.
To summarise what I was trying to achieve is to automatically detect if that string value equals 'enabled' and if it does it returns the string name inside the message box
Example :
Example of MessageBox How I Need It Displayed
Please Help
Instead of putting everything inside the DialogResult constructor,
Since you do have Settings where you store these settings, either go through them in another method
or query them in key-value fashion flags indicating disabled, i.e.,
String dialogRes = String.Empty;
if(String.isNullorEmpty(SettingObj["mySetting"].toString())
{
dialogRes = $#"{dialogRes}
{SettingObj["mySetting"].toString()}"; //format it your way with "#" spacing
}
Once you have this dialogRes, display it, if the user says yes, turn all your setting strings null or empty.
I want to ask you guys if it is possible to do the following:
Type in textbox something like this "search pluto"
and then it must search for that last word.
This is how I did it but it doens't work because when I do that
my browser opens up twice.
One with "https://www.google.be/#q="
and the other tab that opens is the word that I wrote in
the textbox. Can somebody help me out of this please?
This is the code for this:
string url = "https://www.google.be/#
if (inputTBX.Text.Contains("search ") == true)
{
inputTBX.Text.Replace("search ", "");
string URL = url += inputTBX.Text;
Process.Start(#"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
URL);
inputTBX.Clear();
}
just as a test in a simple console app I tried the following and it worked launching my default browser
var t = "pluto";
Process.Start("http://google.com/search?q=" + t);
This also works
var t = "pluto";
Process.Start("https://www.google.be/search?q=" + t);
in your case you need to get your query string to be the following
https://www.google.be/#q=pluto
your first problem is that you are trying to use the Replace method but you need to assign it into something here is a working solution of your code just tested notice the differences in what I have done
inputTBX.Test = "search pluto";
string url = "https://www.google.be/search?q=";
if (inputTBX.Contains("search "))
{
inputTBX.Text = inputTBX.Replace("search ", "");
string URL = url += inputTBX;
Process.Start(URL); // this will launch your default web browser
inputTBX.Clear();
}
since your query string has the word search in it.. you really don't need this line if (inputTBX.Contains("search ")) but if you keep it it will work with if you pass search planet pluto for example in your textbox
This part
inputTBX.Text.Replace("search ", "");
Is seriously bad, because it will fail to do its job if you have input string like this
"search research on Beethoven's work"
If you want the key phrase to be "search ", you should do this instead
inputTBX.Text.Substring(("search ").Length); //this way it will skip the "search " phrase and use the rests of the phrase for searching
As for your process with the given URL, simply do
string url = "https://www.google.be/#q="; //notice the q= is missing in your code shown
Process.Start(url + inputTBX.Text.Substring(("search ").Length));
In my Windows Phone 7 application I want to send an e-mail where the message body should contain the data from my previous page in my application. Previously I just integrated the e-mail facility like this:
private void Image_Email(object sender, RoutedEventArgs e)
{
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "message subject";
emailComposeTask.Body = "message body";
emailComposeTask.To = "recipient#example.com";
emailComposeTask.Cc = "cc#example.com";
emailComposeTask.Bcc = "bcc#example.com";
emailComposeTask.Show();
}
But I was not able to test this in my emulator. Now in the body part I want my data from the previous page. So how to do this?
Updated code:
if (this.NavigationContext.QueryString.ContainsKey("Date_Start"))
{
//if it is available, get parameter value
date = NavigationContext.QueryString["Date_Start"];
datee.Text = date;
}
if (this.NavigationContext.QueryString.ContainsKey("News_Title"))
{
//if it is available, get parameter value
ntitle = NavigationContext.QueryString["News_Title"];
title.Text = ntitle;
}
if (this.NavigationContext.QueryString.ContainsKey("News_Description"))
{
ndes = NavigationContext.QueryString["News_Description"];
description.Text = ndes;
}
Now what do I write in the message body? I am not able to test it as I do not have a device.
Can i pass in the values like this:
emailComposeTask.Body = "title, ndes, date";
I think the code is correct. if you want to pass body from previous page, you need to pass it when page navigation. and set emailComposeTask.Body = yourPassedValue.
like this:
var date;
var title;
var ndes;
emailComposeTask.Body = title + "," + ndes + "," + date;
You need to edit your message body line like this:
emailComposeTask.Body = title+" "+ ndes+" "+ date;
You cannot test sending mail in the emulator since you don't have a proper email account set up. Nor you could set it up in the emulator.
The Body property is a string so you can put inside pretty much anything you want.
Using the following code will only generate a string containing exactly that:
emailComposeTask.Body = "title, ndes, date";
So the result mail will have a body containing "title, ndes, date" as a text. If you want to replace the title with the value from the local variable named title, you need to use the following syntax:
emailComposeTask.Body = string.Format("{0}, {1}, {2}", title, nodes, date);
Good day so here is my code
Page.ClientScript.RegisterStartupScript(this.GetType(), "messagebox", "<script>$(document).ready( function() { csscody.alert('<br/><h1> Exception</h1><br/>The file that you have selected has Invalid/No matching Branch Code in our Database'"+Message+"',{onComplete: function(e){if(e){process();__doPostBack('ctl00$ContentPlaceHolder1$btndelete','');}}});return false;});</script>", false);
The problem is when i put the Variable Message inside the pop up doens't show (maybe its a syntax error) but when i remove it it shows as usall, so how would i add a text/String from C# to the code above? the Message variable contains this text
String Message = 123123 <br/> 22222 <br/> 1233 <br/> 33123 <br/>
You are closing your single quotes before you append the Message string. (Actually I think it's a stray single quote.) Try:
...anch Code in our Database" + Message + "'...
try
Page.ClientScript.RegisterStartupScript(this.GetType(), "messagebox", "<script>$(document).ready( function() { csscody.alert('<br/><h1> Exception</h1><br/>The file that you have selected has Invalid/No matching Branch Code in our Database\\''"+Message+"\\',{onComplete: function(e){if(e){process();__doPostBack('ctl00$ContentPlaceHolder1$btndelete','');}}});return false;});</script>", false);