Search
Showing posts with label ASP.Net. Show all posts
Showing posts with label ASP.Net. Show all posts
Tuesday, August 26, 2008
C#: Popup a window from ASPX
C#: Popup a window from ASPX
public static void popUpWindow(System.Web.UI.Page page, string url)
{
string js = "";
page.RegisterClientScriptBlock("PopUpWindow", js);
}
Monday, August 25, 2008
How to send a mail from the ASP.NET web form
How to send a mail from the ASP.NET web form.
In .NET 2.0 we have SmtpClient class that allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).
Namespace: System.Net.Mail
Example
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if(!validateFields())
return;
SmtpClient smtpClient = new SmtpClient(host, port);
smtpClient.Credentials = new NetworkCredential(user, password);
MailAddress from = new MailAddress(EmailBox.Text, NameBox.Text);
MailAddress to = new MailAddress(to_mail);
MailMessage message = new MailMessage(from, to);
message.Subject = string.Format(subject_template, NameBox.Text, PhoneBox.Text);
message.Body = QuestionBox.Text;
try
{
smtpClient.Send(message);
Response.Redirect(redirect_success,true);
}
catch(Exception ex)
{
ErrorMessage = ex.Message;
Response.Redirect(redirect_error, true);
}
}
Friday, April 4, 2008
Web config notes for ASP website ( password rule config, max upload file, deny annon user to access specific pages
add additional setting:
add:
<appSettings> <add key="SiteName" value="yoursitename"/> </appSettings>
to change default annoying password rule in ASP.Net (web.config):
overview: we will delete a provider named AspNetSqlMembershipProvider then
we add new requirements: minRequiredPasswordLength="4", minRequiredNonalphanumericCharacters="0", and passwordStrengthRegularExpression="". means that, we can set password: min 4 chars, no non-alphanumeric needed and no rule for expression.
add this code below <system.web>
<membership>
<providers> <remove name="AspNetSqlMembershipProvider"/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5"passwordAttemptWindow="10" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression=""/> </providers> </membership>
change maximum file upload: 8192 KB.
add below <system.web>
<httpRuntime maxRequestLength="8192"></httpRuntime>
deny annon user to access specific pages:
add the following in tag <configuration> and after tag <appSettings>
<location path="page1.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="page2.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="page3.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
Thursday, April 3, 2008
Asp control Hyperlink
<asp:HyperLink id="value" Runat="Server"
ImageUrl="url"
NavigateUrl="url"
Target="_blank|_self|_top|_parent|framename"
Text="string"
property="value"
Style="CSS style settings..."
/>
more:
http://msconline.maconstate.edu/tutorials/ASPNET20/default.htm
Subscribe to:
Posts (Atom)
