Posted by gondar |
Filed under code, html, rearrenge, identation, tabs
in visual studio go to:
Tools > Options > Text Editor > HTML > Miscellaneous
and select the "Format HTML on paste", and press the ok button.
after this, if you copy and paste some html code, it will be well formated.
hope it helps.
a52cad31-f126-4284-a53d-cb00ac4d5d1b|0|.0
Posted by gondar |
Filed under membership, user, changepassword
very often, users forget theyr passwords.. we could add a passwordrecovery control and/or the admin could change it, without problems.
credits for this post: http://forums.asp.net/p/965209/1206792.aspx
1º - in our web.config file, we need to add a second provider (AspNetSqlMembershipProvider > AspNetSqlMembershipProvider_2, for ex.)
2º - change some settings (at least this 2):
enablePasswordReset="true" requiresQuestionAndAnswer="false"
3º - the code:
//instantiate the 2 provider, wich doesnt require passwordAnswer
MembershipProvider mp = Membership.Providers["AspNetSqlMembershipProvider_2"];
//instantiate the user to changepassword
MembershipUser user = mp.GetUser(__username__, false);
//with the principal provider we get the user information, and pass a resetpassword with the 2 provider
//wich will return a new password generated, and then the new password
Membership.GetUser(__username__).ChangePassword(user.ResetPassword(), "__NewPassword__");
hope it helps [[]]
e08bab5f-9398-41b1-a9ce-35fba25c5431|0|.0
Posted by gondar |
Filed under excel, asp.net, xls
the credits for this goes to: http://csharp.net-informations.com/excel/csharp-create-excel.htm
1º - using Excel = Microsoft.Office.Interop.Excel;
2º - Project > Add Reference
3º - in the COM separator select "Microsoft Excel 12.0Object Library"
4º - paste the following code:
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Cells[1, 1] = "hello 1";
xlWorkSheet.Cells[1, 2] = "hello 2";
xlWorkBook.SaveAs("c:\\excelFile.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook.Close(true, misValue, misValue);xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
}
private void releaseObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch (Exception ex)
{
obj = null;
MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
}
finally
{
GC.Collect();
}
}
}
}
hope it helps [[]]
dc151a06-591c-4c0e-97df-7158a8a7309f|0|.0