|
i have a page containing multiple textboxes which have menu items which i want to store into mysql database. These items would be stored in "menu_items" column of table. i want code to store these values into database
modified on Monday, August 10, 2009 3:58 AM
|
|
|
|
|
Alright, and the problem is?
|
|
|
|
|
SO you have made as if you know what you are doing Its easy why dont you ask
(How do i run an insert to mySQL Table) then we will answer you. Now another thing is that before you post you must first Google. there are plenty of examples on the net
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
HI
i have create a project having VSJLIB reference in it
when i have code it as follows
public void CreateZipFile(string sPath)
{
FileOutputStream stream1 = null;
ZipOutputStream stream2 = null;
if (System.IO.File.Exists(sPath))
{
FileInfo info2 = new FileInfo(sPath);
stream1 = new FileOutputStream(sPath.Replace
(info2.Extension, ".zip"));
stream2 = new ZipOutputStream(stream1);
this.ZipOneFile(stream1, stream2, sPath);
}
else if (Directory.Exists(sPath))
{
stream1 = new FileOutputStream(sPath + ".zip");
stream2 = new ZipOutputStream(stream1);
DirectoryInfo info1 = new DirectoryInfo(sPath);
this.ZipDirectory(stream1, stream2, info1, sPath);
}
stream2.close();
stream1.close();
stream2.flush();
stream1.flush();
}
private void CopyStream(FileInputStream src, ZipOutputStream
dest)
{
InputStreamReader reader1 = new InputStreamReader(src);
OutputStreamWriter writer1 = new OutputStreamWriter(dest);
while (reader1.ready())
{
writer1.write(reader1.read());
}
writer1.flush();
}
private void ZipDirectory(FileOutputStream fos, ZipOutputStream
zos, DirectoryInfo di, string SRootDir)
{
FileInfo[] infoArray2 = di.GetFiles();
foreach (FileInfo info2 in infoArray2)
{
ZipEntry entry1 = new ZipEntry
(info2.FullName.Substring(SRootDir.LastIndexOf(@"\")));
entry1.setMethod(8);
zos.putNextEntry(entry1);
FileInputStream stream1 = new FileInputStream
(info2.FullName);
this.CopyStream(stream1, zos);
zos.closeEntry();
stream1.close();
}
DirectoryInfo[] infoArray1 = di.GetDirectories();
foreach (DirectoryInfo info1 in infoArray1)
{
this.ZipDirectory(fos, zos, info1, SRootDir);
}
}
but when i run the code it gives me excetion
java.io.File.getCanonicalPath()
what should i do to run the code ???
any suggesations ???
thanx in advnace
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
i want to change the url property of the embeded object(media player) in my webpage....
is it possible through javascript or codebehind. sample code help???? thnks in advance
|
|
|
|
|
That Should be Easy in your markup not server site , there is an <embed /> tag, inside it , there is an object and a URL, just change the URL there.
Hope this Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
thanks but i want to change it dynamically.....
|
|
|
|
|
It is Still Simple. That object has an object ID , so on server side you can do that dynamically by calling the object id
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I m facing 'originalWidth' is null or not an object javascript error on my aspx web page, i m hiding and showing panel based on checkbox, the panel contains some of the ajax validationCalloutExtender controls , when i m clicking on submit button i m getting the error as -
'originalWidth' is null or not an object"
Can someone help regarding this issue.
Thanks in advanced
Rahul
|
|
|
|
|
I have a small survey application that I put together within an ASP.NET CMS (sitefinity). The logic of the survey is to store the SelectedItems from the various button list controls in hidden fields (upon button clicks). As each question is answered a new panel of questions is made visible and the answered questions are hidden.
Upon completion the final event is to email the SelectedItems along with a large HTML message to the user. The SelectedValues are placed in various locations of the HTML message. A mail merge if you will.
Here is my problem: I can only get the SelectedItems into the HTML message under certain limited conditions.
1. Using a Token Replacement scheme allows me to "Tokenize" the fields within a static ASPX page. However, the tokens can't be linked to the server controls (the hidden fields) inside of the user control .ascx file.
Here is an example of my code for this situation.
.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NeedsSurvey.ascx.cs" Inherits="NeedsSurvey_NeedsSurvey" ClassName="NeedSurvey" %>
<asp:Panel runat="server" ID="panel1">
1. Which of the following best describes the personal needs you feel are the most
immediate?
<br />
<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>Help with everday expenses</asp:ListItem>
<asp:ListItem>Paying off debt</asp:ListItem>
<asp:ListItem>Taking a vacation</asp:ListItem>
<asp:ListItem>Home improvments</asp:ListItem>
<asp:ListItem>Better medical coverage</asp:ListItem>
</asp:RadioButtonList>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="btn_Click1" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadioButtonList1"
ErrorMessage="Please select an answer"></asp:RequiredFieldValidator>
</asp:Panel>
<asp:HiddenField ID="q1" runat="server" />
Here is the code behind
.ascs.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;
using System.IO;
public partial class NeedsSurvey_NeedsSurvey : System.Web.UI.UserControl
{
#region EventHandlers
protected void btn_Click1(object sender, EventArgs e)
{
try
{
panel1.Visible = false;
panel2.Visible = true;
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
q1.Value = RadioButtonList1.SelectedItem.Text;
}
#endregion
public void Confirm_Send(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("xxx.com");
mail.To.Add("xxx.com");
mail.Subject = "Website Lead";
string html = ScreenScrapeHtml("http://localhost/demo/mycontrols/needssurvey.aspx");
mail.Body = html;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("xxx.com");
smtp.Credentials = new System.Net.NetworkCredential("xxx", "xxx");
smtp.Send(mail);
}
public string ScreenScrapeHtml(string url)
{
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
}
}
The ASPX page is just an HTML formatted message that looks like, "Dear [$FirstName$], etc" with a code behind file for Tokenizing. The code for this was written by Damon Armstrong and can be found Here. I used the code exactly as written. Again, the problem is I can't get my hidden fields to link to the external ASPX page nor can I tokenize them.
2. The other method is to place the html message in the User Control within a Literal control and call the control at the SEND email event. Unfortunately you can not place server controls within a Literal control to call the values of the hidden fields, nor is it possible to use a because System.Net.Mail returns an error that the contents of the are not literal.
It is possible to Tokenize the fields (because the token code is used within the User Control, the hidden fields are available, unlike the external ASPX method) within the Literal control but they will only render on PageLoad. Calling the Literal control and sending through System.Net.Mail does not render the tokens only "Dear [$FirstName$], NOT Dear John.
Sorry for the length of this, but I wanted to make sure I included everything I tried.
One final Note. I do know that I can use server control fields using System.Net.Mail, but my HTML message is much more long and complicated to make that a viable solution.
Thanks.
joe
|
|
|
|
|
How web owners r making money by sending free sms for free registered users? eg: 160by2.com, way2sms.com
|
|
|
|
|
Well, not really a programming question. But let us think about this: How is Google making money? Right, advertising. So I guess the sites you mentioned are full of commercials. That is how they make money...
Regards
Sebastian
|
|
|
|
|
This has nothing to do with ASP.NET .
|
|
|
|
|
How to store and retrive multilinetext(Not single line) from textbox in to sql server.
|
|
|
|
|
Hi,
depends on how the user entered the text. If he used "Return" to do a line break, the character for this well be stored in the database. So when you read the value from your db again and place it into the textbox the text will be formatted as before.
If the user didn't use "Return" the textbox will do a line break automatically, so within your db the text will be stored without the line break. But if you put the text back into the textbox the text will be formatted as before.
So after all you don't have to do anything special with your db to support multiline text (it is just a matter of your UI formatting the text).
So my question is: What do you want to achieve?
Regards
Sebastian
|
|
|
|
|
When i enter
shankar,
India,
641636.
means its stored in db but i can't retrive it again.
but when i entered like this means,
shankar,India,641636.
I can able to retrive it from db.
so how to solve this problem?
|
|
|
|
|
Hi,
you can retrieve both inputs from your db. If you debug your app you will see that when entering the first input it will be retrieved like this "shankar\r\nIndia\r\n641636". The value you put in your db is the same you will retrieve.
So you did you tried it and it doesn't work? If yes, maybe you could post a bit of your code...
Regards
Sebastian
|
|
|
|
|
<asp:TextBox ID="TextBox6address" runat="server" Height="72px" TextMode="MultiLine" Width="178px" MaxLength="500"></asp:TextBox></td>
<td style="width: 207px; height: 54px">
cmd = new SqlCommand("insert into AdminAccount (UserName,Password,Email,Address,City,Pincode,PhoneNo,MobileNo) values('" + TextBox1username.Text.ToString() + "','" + TextBox2password.Text.ToString() + "','" + TextBox4email.Text.ToString() + "','" + TextBox6address.Text.ToString() + "','" + TextBox7city.Text.ToString() + "','" + TextBox8pincode.Text.ToString() + "','" + TextBox9phoneno.Text.ToString() + "','" + TextBox10mobileno.Text.ToString() + "')", con);
Datatype is varchar(Max)
Textbox's textmode is Multiline
|
|
|
|
|
1. Why are you using Textbox.Text.ToString()? Textbox.Text should be sufficient.
2. Wouldn't use string-concatenation for all the values. Maybe using PreparedStatements will be better (SQL-Injection)
3. Did you try to debug your app, before you store the value? Does this value contains the "\r\n" I mentioned before?
4. Abhijit mentioned an answer he gave to you before? How did you add the code he mentioned to yours?
|
|
|
|
|
kavinnagarajan wrote: How to store and retrive multilinetext(Not single line) from textbox in to sql server
Did you tried the way I have suggested to two days back ?
|
|
|
|
|
Its not working correctly for me. Please send a code for this
|
|
|
|
|
kavinnagarajan wrote: Its not working correctly for me
Then you should asked me over there, rather than creating a new thread. .
I do a good followup
|
|
|
|
|
|
No Problem.
|
|
|
|
|
But still i cant resolve from that problem
so please send a sample code for that, how to store & retrive multiline text from textbox in to sql server
|
|
|
|