|
I would personally loop al the controls and then store as session variables, that is my preferred choice, obviosuly the session variables can expire though
|
|
|
|
|
Hi every one!
I'm making a composite web custom control which includes an ImageButton so I want to access it's Click event in design mode in property. I have some code like below in my program and it works! but when in a web page I use the event method both of my control event method in web pge and my control event method in the control library class run, but I want some thing like overriding it!
thanks for any help
here is the code:
//in my constructor:
_imageButton.Click += new ImageClickEventHandler(_imageButton_Click)
//and then:
public virtual void _imageButton_Click(object sender, ImageClickEventArgs e)
{
if (Convert.ToInt32(_rowID)!= -1)
{
_textContainer.Text = _tableAdapter.GetData()[Convert.ToInt32(_rowID)].FDtext;
}
}
//so I defined my event like this:
[Browsable(true)]
public event ImageClickEventHandler TitleClicked2
{
add
{
_imageButton.Click += value;
}
remove
{
_imageButton.Click -= value;
}
}
|
|
|
|
|
this seems like a vary clunky way to code what your trying to do, any1 else agree?
surely you just have the onclick event and then the button and thats it
|
|
|
|
|
Hi,
I wrote a code for sending mail but when runninin the page this error appears :
No connection could be made because the target machine actively refused it (an IP):25
Why ?
Best wishes
|
|
|
|
|
A number of things could be the problem including the following:
The port is blocked
Or you are using the wrong port
Can you post your code as well please
|
|
|
|
|
I guess your mail server settings are wrong.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Recently I have fixed the problem by configuring the IIS setting on your m/c.
In Default SMTP server of your (IIS) Choose Access Tab and Configure Rely with IP 127.0.0.1.
Then restart the smtp service.
Hope it will helps you
|
|
|
|
|
HI All
can anybody tell me how to find substring count occurs in a string in asp.net C#.
for example..
string str = "Ram was not there. Ram has been gone to market";
if I wand to find count of "Ram" in this string , then it should return 2
please help me..
thanks
|
|
|
|
|
//Function to count no.of occurences of Substring in Main string
public static int CharCount(String strSource,String strToCount)
{
int iCount=0;
int iPos=strSource.IndexOf(strToCount);
while(iPos!=-1)
{
iCount++;
strSource=strSource.Substring(iPos+1);
iPos=strSource.IndexOf(strToCount);
}
return iCount;
}
|
|
|
|
|
|
This is a C# question. The easiest way probably is to call the split method and see how many elements it returns.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello friends
I have generated the web.sitemap file from the databse in my c drive.
Now I am facing problem while binding this to ths menu control please help....
Deepak Nigam
|
|
|
|
|
Please can you explain exactly what your problem is
|
|
|
|
|
Hi all...
I have a login form (username and password), and I want to add a checkbox (remember me), how can I perform this cookie?
Thanks alot
Nour Abdel-Salam...
A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
|
|
|
|
|
This article shows you how to implement the above functionality in ASP.NET.
Step 1: Add a checkbox in the login page
You can add a checkbox in the login page by dragging and dropping a checkbox from the toolbox when you are in page design mode, or you can create a checkbox programmatically in the code behind class.
The following code shows you how to do this in the second way:
private CheckBox _rememberMeCheckBox;
//.....
this._rememberMeCheckBox = new CheckBox();
this._rememberMeCheckBox.Text = "Remember me next time");
this._rememberMeCheckBox.Checked = true;
this.Controls.Add(this._rememberMeCheckBox);
//.....
Setp 2: Creat a cookie when a subscriber login
create a cookie in the Cliked event handler of the login button:
private void _LoginButton_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
//....
//....
ApplicationUser user = ApplicationUser.RetrieveCurrentUserByLoginId(userId);
if (user != null && user.Password == password)
{
Session["user"] = user;
Response.Cookies.Remove("CookieFromXXX");
if (this._rememberMeCheckBox != null &&
this._rememberMeCheckBox.Checked)
{
HttpCookie cookie = new HttpCookie(string.Format("cookie_from_{0}", this._host));
cookie.Values.Add("userId", user.Id);
cookie.Values.Add("pwd", user.Password);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
}
}
//....
//....
}
Step 3: Override the OnInit method in the base page
If there is a base page which is the parent page of all other pages in your website, you can override the the OnInit method in the base page like the following code:
override protected void OnInit(EventArgs e)
{
//....
//....
if (!IsPostBack && Session["user"] == null)
{
if (Request.Cookies["CookieFromXXX"] != null)
{
HttpCookie cookie = Request.Cookies["CookieFromXXX"];
string userId = cookie.Values["userId"].ToString();
string pwd = cookie.Values["pwd"].ToString();
ApplicationUser user = ApplicationUser.RetrieveCurrentUserByLoginId(userId);
if (user != null user.Password == pwd)
{
Session["user"] = user;
}
}
}
base.OnInit(e);
}
Or you can add the above logic in the OnLoad method in the home page.
Step 4: Use the Session["user"] to determine the subscriber logged in or not
In any web page, you can check the Session["user"] to determine the subscriber logged in or not, see the following code:
if (Session["user"] != null)
{
//logged in already
//....
}
else
{
//haven't logged in yet
//....
}
Step 5: Expire the cookie when subscriber logout the website
Add the following code to expire the cookie when subscribers logout the website.
this.Session.Clear();
if (Response.Cookies["CookieFromXXX{0}"] != null)
{
//Response.Cookies.Remove("CookieFromXXX");
Response.Cookies["CookieFromXXX"].Expires = DateTime.Now.AddDays(-1);
}
Response.Redirect("./homepage.aspx");
|
|
|
|
|
could you please write it using VB.NET
Thanks alot
Nour Abdel-Salam...
A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
|
|
|
|
|
why don't you try converting it yourself, there are plenty of converters out there and the rest you cvould probably do yourself
|
|
|
|
|
I did it
thanks alot
regards
Nour Abdel-Salam...
A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
|
|
|
|
|
i have stored excel file in database i have to display it in a panel control. now my excel file is opening in a seperate window. i have written this code in page load event
my code is
try
{
string val = Session["f"].ToString();
connect = ConfigurationManager.AppSettings["connection"].ToString();
SqlConnection Sqlcon = new SqlConnection(connect);
string ssql = "select contents from reports where modulename='"+val+"'";
Sqlcon.Open();
DataTable dt = new DataTable();
SqlDataAdapter Sqladp = new SqlDataAdapter(ssql, Sqlcon);
Sqladp.Fill(dt);
int count = dt.Rows.Count;
for (int i = 0; i < count; i++)
{
byte[] file = (byte[])dt.Rows[i]["contents"];
// Response.ContentType = "application/ms-excel";
Response.ContentType = "application/xls";
//Response.BinaryWrite(file);
Response.OutputStream.Write(file, 0, file.Length);
//Response.End();
}
Sqlcon.Close();
}
catch (Exception EX)
{
string ERR = EX.Message;
}
finally
{
//Sqlcon.Close();
}
plz help to display in panel control
|
|
|
|
|
Don't double post. It's rude. People will ignore both your original message and this one.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi friends,
i am using ftpwebrequest to upload files on ftp server here is my code.
string uri = "ftp://myuserid:mypwd@ftp.shopzilla.com/myfile.txt";
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
reqFTP.Proxy = null;
reqFTP.Credentials = new NetworkCredential("myuserid", "mypwd");
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.ContentLength = fileInf.Length;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
FileStream fs = fileInf.OpenRead();
try
{
Stream strm = reqFTP.GetRequestStream();
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
strm.Close();
fs.Close();
}
catch (WebException webEx)
{
WriteLog("Adding to Bizrate webex : " + webEx.Response.ToString());
WriteLog("Adding to Bizrate webex : " + webEx.Status.ToString());
WriteLog("Adding to Bizrate webex : " + webEx.Message);
}
catch (Exception ex)
{
WriteLog("Adding to Bizrate : " + ex.Message);
}
i am getting error
The remote name could not be resolved: 'ftp.shopzilla.com'
and status NameResolutionFailure
please give me any solution or link to solve this
Thanking you,
Laxmikant Lad
|
|
|
|
|
Hi
I have two database table there structure as follows..
ADA_category
catid catname status amount
and second table contain
ADA_Question
qid catid question status
I am adding question in each category and displaying category to the user in datagrid. But i want to display only those category which having more that or equal to 25 question.
How can i do this in a single query.
Please guide me.
Thanks I solved the problem
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
modified on Tuesday, March 18, 2008 2:21 AM
|
|
|
|
|
i have stored excel file in database i have display it in panel control.
my code is
try
{
string val = Session["f"].ToString();
connect = ConfigurationManager.AppSettings["connection"].ToString();
SqlConnection Sqlcon = new SqlConnection(connect);
string ssql = "select contents from reports where modulename='"+val+"'";
Sqlcon.Open();
DataTable dt = new DataTable();
SqlDataAdapter Sqladp = new SqlDataAdapter(ssql, Sqlcon);
Sqladp.Fill(dt);
int count = dt.Rows.Count;
for (int i = 0; i < count; i++)
{
byte[] file = (byte[])dt.Rows[i]["contents"];
// Response.ContentType = "application/ms-excel";
Response.ContentType = "application/xls";
//Response.BinaryWrite(file);
Response.OutputStream.Write(file, 0, file.Length);
//Response.End();
}
Sqlcon.Close();
}
catch (Exception EX)
{
string ERR = EX.Message;
}
finally
{
//Sqlcon.Close();
}
|
|
|
|
|
Have you solved this? How about using Office Interop?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Hello friends,
I have created my first application in .Net 2005 but i am not able to find the .dll file.
Can anybody tell me where the .dll file of the application get saved?
Thanks,
Nagendra.
|
|
|
|