|
You created 2 SmtpClient Objects, you must of mixed up the object that sends
You really should structure your code better, because that was a hard read. I don't see why you would build your message body via sql in the middle of your email function,
Why not build your html message first, and then pass the message to the smtp function, in which you set your parameters, and send the message.
You didn't attach the message (msg) to the smtp object, sloppy code will produce errors, that you can't see.
|
|
|
|
|
Try this:
MailMessage Msg = new MailMessage();
Msg.To.Add( new MailAddress(TxtEmail .Text .Trim ()));
Msg.From = "tehnical@mydomain.com";
Msg.IsBodyHtml = true;
Msg.Subject = "Login Details";
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.mydomain.com";
smtp.Port = 1234;
smtp.EnableSsl = GmailSSL;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("tehnical@mydomain.com","password");
smtp.Send(Msg);
|
|
|
|
|
In a C# 2010 web form application that uses web form controls, I have a scrollbar used on a panel control. The user would like to be able to retain the scrollbar position while they are on the current web form page. They would like the scrollbar to retain its position until they have pointed to the next web form page. Since I do not know how to accomplish this goal, I am wondering how to accomplish this task.
The asp.net markup looks like the following:
<asp:Panel ID="Panel1" runat="server" ScrollBars="Auto" Height="130px" Width="455" CssClass="TextBoxStyle"> <asp:CheckBoxList ID="ChkBoxLst" runat="server" AutoPostBack="true"> </asp:CheckBoxList> </asp:Panel>
|
|
|
|
|
|
Thanks for your answer. However that did not work.
There is no postback involved most of the time.
Basically I placed a checkbox list control within a panel that has a scrollbar.
When the user has finished selecting all the items in the checkbox list control, they move on to other items on the web form page to enter. They have not clicked the 'next' button yet. There is no postback.
The user does not want the scrollbar to go to the top area of the scroll. They want to stay where they left off entering selections.
Thus do you know of other ways I can maintain the scrollbar position? I am currently not using ajax controls on this webpage.
|
|
|
|
|
|
I think what the OP is trying to say,
Is that he has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top.
How do I reset the scroll position to where the user left it, during a partial or whole page postback.
|
|
|
|
|
I guess I misunderstood this statement...
Quote: They have not clicked the 'next' button yet. There is no postback.
|
|
|
|
|
no your fine.
I'm still trying to understand the question. My rephrase was the only thing that made any sense.
It's like one of those detective shows, and you have to figure out the crime based on the written statement of the OP.
|
|
|
|
|
You are correct. This is what I am trying to say:
There has a form with a checkbox in a tall panel with scrollbars set to auto. The user clicks on the checkbox, and it alters the form, and during the parital or whole page postback, the panel scroll position defaults back to the top.
How do I reset the scroll position to where the user left it, during a partial or whole page postback.
|
|
|
|
|
|
Yah
I think I just posted the same link
Good job!
|
|
|
|
|
Thats too funny. Looks like you covered it a little better than I did though so good job to you!
|
|
|
|
|
Thanks,
I figured the question was wrong, and the OP had no clue what was happening there.
Well, hopefully, he learned something there today.
These asp.net questions are getting harder to answer because the way the questions are phrased make no sense to me.
One day, someone will ask a really good question
Over and out, time to sleep
|
|
|
|
|
Aw, The page lifecycle
OnInit, Intialize the html elements on the page
onLoad, load values for the html elements
once the page does onInit, the html elements are cast in stone, and will not change
Once the page does onLoad, you can populate values in the html elements
During a postback to the server, the html elements are rock solid, and the values will remain, but things like scroll position reset back to default. The page does not have the ability to remember little details like scroll position
MaintainScrollPosition is for the scroll of the whole page, and not a panel.
But, maybe, instead of page.MaintainScrollPosiiton, you could do panelName.MaintainScrollPosition
Other that that, you would have to take a measurement of the position, record it, and restore it back to the value, in theory
I don't have an answer, I would have to think about it and experiment.
A quick search gets this document.getElementById('box').scrollTop
Persisting the scroll position of a DIV on AJAX postbacks [^]
Maintain Scroll Position in Panel, Div[^]
http://michaelsync.net/2006/06/30/maintain-scroll-position-of-div-using-javascript-aspnet-20[^]
http://forums.asp.net/t/1359867.aspx[^]
|
|
|
|
|
dcof wrote: There is no postback involved most of the time.
dcof wrote: There is no postback.The user does not want the scrollbar to go to the top area of the scroll. T
Well, not possible! Without a postback, page would not return scroll to top by itself!
My answer still holds. Try out. Both the options. For second one, use form onsubmit() event to store the scroll position and then restore it on form load.
|
|
|
|
|
Use Smartnavigation = true property hope it will suits your requirement.
|
|
|
|
|
Oh yes, I totally forgot about it!
|
|
|
|
|
You probably forgot because your first suggestion is the replacement for the deprecated property.
[BrowsableAttribute(false)]
[ObsoleteAttribute("The recommended alternative is Page.SetFocus and Page.MaintainScrollPositionOnPostBack. http://go.microsoft.com/fwlink/?linkid=14202")]
public bool SmartNavigation { get; set; }
http://msdn.microsoft.com/en-us/library/system.web.ui.page.smartnavigation.aspx[^]
|
|
|
|
|
5!
Thanks for bringing back some part of memory.
|
|
|
|
|
How we can find html radio button id in asp.net in side datalist control.
....................
Thanks
|
|
|
|
|
Even though the person who asked this in Q&A has different user id, he had same question that I replied here: access to html radio button that created dynamically[^]
You cannot write anything here to access them. You made a HTML control and not server control. HTML controls cannot be accessed on server side codebase.
|
|
|
|
|
I am using this code to save file to MySQL but when I try to open the file after saving it I get an error saying:
Word was unable to read this document. It may be corrupt.
here is the code to write:
file_name = Path.GetFileName(uploadResume.PostedFile.FileName);
file_extension = Path.GetExtension(uploadResume.PostedFile.FileName);
switch (file_extension)
{
case ".pdf": document_type = "application/pdf"; break;
case ".doc": document_type = "application/vnd.ms-word"; break;
case ".docx": document_type = "application/vnd.ms-word"; break;
case ".gif": document_type = "image/gif"; break;
case ".png": document_type = "image/png"; break;
case ".jpg": document_type = "image/jpg"; break;
case ".jpeg": document_type = "image/jpg"; break;
}
int file_size = uploadResume.PostedFile.ContentLength;
byte[] document_binary = new byte[file_size];
uploadResume.PostedFile.InputStream.Read(document_binary, 0, file_size);
and then passing it as parameters:
sql_command.Parameters.AddWithValue("param_resume_format", document_type).MySqlDbType = MySqlDbType.VarChar;
sql_command.Parameters.Add("param_resume_data", MySqlDbType.Blob, file_size).Value = document_binary;
and here is how I am retrieving it:
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("sp_get_resume_by_id", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.Add("param_resume_id", MySqlDbType.Int32).Value = resume_id;
sql_reader = sql_command.ExecuteReader();
sql_reader.Read();
if (sql_reader.HasRows)
{
file_name = sql_reader["resume_id"].ToString() + sql_reader["resume_ext"].ToString();
byte[] document_binary = (byte[])sql_reader["resume_data"];
FileStream file_stream = new FileStream(@"C:\Temp\" + file_name, FileMode.Create);
file_stream.Write(document_binary, 0, document_binary.Length);
file_stream.Close();
file_stream.Dispose();
txtResume.Visible = true;
}
|
|
|
|
|
In a BLOB, you can store a maximum of 65535 bytes. Check that your file did not get truncated; if necessary, change the field type to MEDIUMBLOB or even LONGBLOB.
|
|
|
|
|
changed to longblob in the code (the parameter) and the MySQL field data type but still getting the same error. Here is the exact error I am getting when I am trying to open the downloaded word file.
This error message can appear if the document you are attempting to open is corrupt. It is possible to recover a corrupt file or its content by using either the Recover Text converter (may require installation) or the Open and Repair feature.
The Open and Repair feature is available from the Open dialog. To open and attempt a repair, click the File tab, click Open, and then navigate to the damaged file and click it once. Instead of clicking the Open button at the bottom right of the dialog box, click the down arrow to the right of the button and select Open and Repair from the menu. If the file can be recovered, it will open and appear in the document work area.
The Recover Text converter, if installed, is available from the Open dialog and appears in the Files of type drop down list. It appears in the drop-down list as Recover Text from Any File (*.*).
For more information, see Microsoft Knowledge Base article 918429.
|
|
|
|