|
^(ftp|http|file):
so
http :
1 2 3 4
so the reg expression would spit out
$1 = http
$2 = www.codeproject.com
$3 = /forum
$4 = /xxx.html
hope this helps.
|
|
|
|
|
Thanks,
How can I store $2 in a string?
|
|
|
|
|
string str = (new Regex("the pattern")).Match("the string").Groups[2].Value;
|
|
|
|
|
It doesn't work with www.codeproject.com
|
|
|
|
|
Try this instead of a Regex:
MessageBox.Show((new Uri("http://rs320tl.rapidshare.com/files/119371167/sth.rar")).Host);
|
|
|
|
|
I didn't know that a Uri broke it down for you - thanks for that! You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Under which namespace .host is come
|
|
|
|
|
I think you mean Uri. It's in the System namespace.
|
|
|
|
|
Thanks, but it throws an Exceptions on
MessageBox.Show((new Uri("rs320tl.rapidshare.com")).Host);
|
|
|
|
|
Try this:
MessageBox.Show((new UriBuilder("rs320tl.rapidshare.com")).Host);
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary;
using System.Collections;
namespace OrderForm
{
public partial class SubForm : Form
{
private TreeView s;
private ComboBox h;
Product c = new Product ();
private double[] prices = new double[100];
Store[] bee = new Store[100];
private string[] quantumItems = new string[4];
private double [] updatePrices = new double[3];
public SubForm()
{
InitializeComponent();
}
public SubForm(ComboBox h,TreeView s)
{
InitializeComponent();
h = new ComboBox();
s = new TreeView();
this.h = h;
this.s = s;
}
public ComboBox superSweet
{
get
{
return h;
}
set
{
h = value;
}
}
public TreeView superAwesome
{
get
{
return s;
}
set
{
s = value;
}
}
private void button2_Click(object sender, EventArgs e)
{
h.Items.Add(txtProduct.Text);
this.Close();
}
private void price_one_TextChanged(object sender, EventArgs e)
{
bee[1] = new Store();
string itemTwo = price_one.Text;
double ItemTwoConvert = Convert.ToDouble(itemTwo);
bee[1].superprice=ItemTwoConvert;
}
private void price_two_TextChanged(object sender, EventArgs e)
{
bee[2] = new Store();
string itemOne = price_two.Text;
double ItemOneConvert = Convert.ToDouble(itemOne);
bee[2].superprice = ItemOneConvert;
}
private void price_three_TextChanged(object sender, EventArgs e)
{
bee[3] = new Store();
string itemThree = price_three.Text;
double itemThreeConvert = Convert.ToDouble(itemThree);
bee[3].superprice = itemThreeConvert;
}
private void button1_Click(object sender, EventArgs e)
{
store_three.Visible = true;
price_three.Visible = true;
}
private void SubForm_Load(object sender, EventArgs e)
{
}
private void txtProduct_TextChanged(object sender, EventArgs e)
{
c = new Product();
c.supername = txtProduct.Text;
c.supercategory = cmbCat.SelectedText;
}
public void myAwesomeItem(string nice,string item,string item3, string item4,string item5, string item6)
{
txtProduct.Text = nice;
cmbCat.Text = item;
store_one.Text = item3;
store_two.Text = item4;
price_one.Text = item5;
price_two.Text = item6;
}
}
}
How would I keep what changes the user makes to the default values?
|
|
|
|
|
Wrap your code in a PRE blocks and specify the language. For example, if I type this into the message editor:
<pre lang="C#">public class MyClass
{
public void MyFunction()
{
MessageBox.Show("Hello");
}
}</pre>
It comes out looking like this:
public class MyClass
{
public void MyFunction()
{
MessageBox.Show("Hello");
}
}
|
|
|
|
|
Nexusfactor wrote: How would I keep what changes the user makes to the default values?
Quote Selected Text
By writing a logic. You could keep default values within another class. and then compare it if needed.
Also please edit your post as aspdotnetdev said it
|
|
|
|
|
|
I see you have created a new login to ask the same question again. And you still posted a link to the code rather than posting the code in your message.
Don't create redundant logins unnecessarily.
Don't repost the same question.
Don't post links to code. Post the code here in your message. Format it well. Make a minimal example instead of posting your full code.
|
|
|
|
|
I have made a contact me form for my website. When I was testing it with f5 in ASP.Net, the contact me page just reloaded itself after I submitted the information (like the Name, Phone Number, Email etc). But I still received the email containing the information I inputted into the Text Boxes in the Form.
So I decided to include a Try-Catch and redirect to a failure or success page depending on if it sent successfully... it always redirected to failure.html but I still received the email which is weird.
So I decided to FTP the site, it still redirects to failure.html but I don't receive any email anymore. There is clearly a problem here. I get no errors and no exception etc, so I have no indication onto where I'm going wrong. I will include all my coding.
contactme.aspx (just the form):
<div runat="server" id="form01">
<table width="325" border="0">
<tr>
<td height="30" class="left"><asp:label runat="server" for="name">Name:</asp:label></td>
<td>
<asp:TextBox runat="server" class="input" type="text" name="name" id="name"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="name" ErrorMessage="Please input your name.">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td height="30" class="left"><asp:label runat="server" for="number">Number:</asp:label></td>
<td><asp:TextBox runat="server" class="input" type="text" name="number" id="number"></asp:TextBox></td>
<td> </td>
</tr>
<tr>
<td height="30" class="left"><asp:label runat="server" for="email">Email:</asp:label></td>
<td><asp:TextBox runat="server" class="input" type="text" name="email" id="email"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="email" ErrorMessage="Please input an email address.">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="email" ErrorMessage="Please enter a valid email address."
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="left"><asp:label runat="server" for="message">Message:</asp:label></td>
<td>
<asp:TextBox runat="server" class="input" name="essage" id="message" cols="45"
rows="3" TextMode="MultiLine"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="message" ErrorMessage="Please input a message.">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="left"> </td>
<td class="right"><label>
<asp:button runat="server" class="submitBtn" name="submit"
Text="Submit" id="cmdSubmit" onclick="submit_Click" /> <asp:ValidationSummary
ID="ValidationSummary" runat="server" CssClass="rightSpec"
DisplayMode="List" />
</label>
</td>
</tr>
</table>
</div>
contactme.aspx.cs:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
public partial class contactme : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void submit_Click(object sender, EventArgs e)
{
MailMessage messageC = new MailMessage();
MailAddress to = new MailAddress("webdesign@malachijones.co.uk");
messageC.To.Add(to);
messageC.From = new MailAddress("webdesign@malachijones.co.uk", "site request");
messageC.Subject = "malachijones.co.uk website request";
messageC.IsBodyHtml = true;
messageC.Body = "<html><head></head><body>" +
"<p></p>" +
"<p><strong>Name:</strong> " + name.Text + "</p>" +
"<p><strong>Phone Number:</strong> " + number.Text + "</p>" +
"<p><strong>Email Address:</strong> " + email.Text + "</p>" +
"<p><strong>Message:</strong> " + message.Text + "</p>" +
"</body></html>";
SmtpClient smtpClient = new SmtpClient("smtpout.europe.secureserver.net");
smtpClient.Credentials = new System.Net.NetworkCredential("webdesign@malachijones.co.uk", "My Password");
smtpClient.Send(messageC);
}
}
web.config:
<system.net>
<mailSettings>
<smtp from="webdesign@malachijones.co.uk">
<network host="smtpout.europe.secureserver.net" port="25" userName="webdesign@malachijones.co.uk" password="My Password"/>
</smtp>
</mailSettings>
</system.net>
Thanks in advance for any help.
Respect,
(*$malli$*)modified on Thursday, February 18, 2010 7:35 PM
|
|
|
|
|
No one is going to read this unformatted garbage
Read
this[^] and pay attention to item #7 I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sorry about that, I have reformatted it.
Respect,
(*$malli$*)
|
|
|
|
|
I have no idea about asp.net, but the first thing I would do is actually try to catch the exception!
try
{
Response.Redirect("success.html");
}
catch(Exception ex)
{
Response.Redirect("failure.html");
}
|
|
|
|
|
Ok thanks for the reply, I'll trying that now.
*EDIT* I posted the exception but it got deleted I think. I changed the catch to:
Response.Redirect("success.html");
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
I had to FTP the site before the exception would show. It kept going to success.html when I tested with Localhost. I didn't receive any email after I FTP'ed either.
Respect,
(*$malli$*)modified on Thursday, February 18, 2010 10:08 PM
|
|
|
|
|
Ok I changed the Catch to this:
Response.Redirect("success.html");
}
catch(Exception ex)
{
Label1.Text = "ex message: " + ex.Message;
}
After I changed it, it redirected to "success.html" and I still got the email, so I decided to FTP it to see if it really was "successful".... It wasnt, and my ex message was: Failure sending mail.
No email and no details at all :/.
Thanks again for the reply.
Respct,
(*$malli$*)
|
|
|
|
|
Have a look at the ex.Innerexception , it may contain a clue as to why it failed if it has a value.
|
|
|
|
|
Where do I place ex.Innerexception please?
Respect,
(*$malli$*)
|
|
|
|
|
put a breakpoint in your catch block and when it's hit, hover your mouse over the ex
You will now be able to examine all the exception's properties including the InnerException[^] property.
|
|
|
|
|
Ok thanks for the help, I got to view it at last...
Now the fact that I get the email when testing through Localhost but not when I FTP the website, does that mean that something is wrong with my SMTP details? here is the top half of the InnerException:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 188.121.53.3:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress
would that IP address maybe be blocked by GoDaddy or something?
Respect,
(*$malli$*)
|
|
|
|