|
|
paddy i guess tats wat i want.......
let me explain.....
the requirement is once the user selects multiple items from the list box,
and submits the form, all the selected values should be inserted into a particular column of the table i,e suppose the listbox has a list if languages say, then all the selected languages from the listbox, should be inserted into the column called "languages", (seperated by comma) of a row in the table.
do you have a solution for this???
|
|
|
|
|
Hi,
The following is the code you can use to get comma separated string of selected Items from the listbox.
string strSelected = "";
foreach ( ListItem lstItem in lstBox.Items )
{
if ( lstItem.Selected )
{
strSelected += lstItem.Value + ",";
}
}
put "strSelected" in to your insert query and you are done.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi Chetan,
Thanks yaar for the code...
its working fine now!!!
|
|
|
|
|
hey Chetan,
wat should i set to ensure that a maximum of only 3 items could be selected from a list box???
is there any property for that or some other code???
please send me the details
|
|
|
|
|
Hi,
There is no such property which you can set get your required functionality.
But you can apply your logic in code behind or in javascript to check how many items are selected.
In code behind you can use GetSelectedIndices() of listbox which will return an array of all the indices of selected items in the listbox.
you can check for the length of that array if it is less than 3.
int[] selectedindices = lstBox.GetSelectedIndices();
string strSelected = "";
if(selectedindices.Length<=3)
{
foreach(int i in selectedindices)
{
strSelected += lstBox.Items[i].Value + ",";
}
}
use strSelected in the Insert query.
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hey Chetan ,
thrz one more issue.......
as soon as i select one item from the list box, the page gets refreshed and the control goes back to the top of the page, then again i ve to scroll down to the list box and select the next item...... how do i handle this???
actually in the listbix properties i ve set auto post back as "true".does this cause any issues?
|
|
|
|
|
Hi,
The AutoPostBack property of your listbox should be set to false if you dont want any server code to be executed when u select an item from the listbox.
So set AutoPostBack property to false for your listbox and it is done.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi Chetan,
I have another requirement.
I need the code for uploading files into the database.
I tried using the FileUpload control in ASP.NET 2.0, and got the code(to be put in the button click event code) to upload the files in my own system in some other location.
However, my requirement is that i should be able to upload the file into a remote system or the SQL database.
Please give me the code for this....
Thank You.
|
|
|
|
|
i tried the following code for upload into mu own system but i don know how to go about and upload in the remote server.Please Help.
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
try
{
//The following line of code specifies the path
FileUpload1.SaveAs("D:\\Uploads\\" +
Label1.Text = "The file has been successfully uploaded in to: " +
"D:\\Uploads\\" + FileUpload1.FileName;
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
else
{
Label1.Text = "Oops! You forgot to specify the file! Browse for the file above.";
}
}
|
|
|
|
|
Hi,
You just need to provide the server path to the SaveAs Function
FileUpload1.SaveAs("http:\\servername\\foldername\\" + filename;
where filename is the name of file you want to upload.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
but i am getting an exception:
ERROR: The SaveAs method is configured to require a rooted path, and the path 'http:\peserver\DART codes.xls' is not rooted
what shall i do????
|
|
|
|
|
Hi Chetan,
I have an issue!!!
I have a dropdown list(somewhere near the bottom) in my page with autopostback set on.
The problem is as soon as i select an item from the list, due to auto postback,the control goes to the top of the page!(the page is long enough, so the user has to scroll down to completely fill the form).
so the user has to again scroll down till bottom of the page.
|
|
|
|
|
Hi,
If you r working on .net 2.0 then you should put MaintainScrollPositionOnPostback="true" in Page directive of your page.
and if u r working on .net 1.1 then you should put SmartNavigation = "true" in page directive of your page.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Yes you can, have a look at this article[^]
|
|
|
|
|
Hello All,
I have written a WCF service in webapplication, so i am adding this class file inside the APP_Code folder so that i refer the functions inside my application.
I am having a problem in configuring the web.config file,using svcconfigeditor.exe tool .
But if i create my WCFService in consoleapplication i get the app.config file using this same tool.
(svcconfigeditor.exe tool )
can i use this tool to configure a web.config file
If anybody knows please tell me
Thanks
any one knows please reply me.
Glenn D'souza
Software Engineer
Quest Informatics
|
|
|
|
|
I am reading paypal's instructions for integrating a custom shopping cart into their payment system on their website.
They state an example would look something like this:
<code><form action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="you@youremail.com">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="0.00">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form></code>
I have concerns with this as hidden fields can be modified as its saved in the html on the client side. Can I simulate this in my codebehind in my aspx.cs file so that I don't have to worry about people messing with the values? I am using c#. What is my best bet?
Thank you
|
|
|
|
|
InvalidTypecast wrote: I have concerns with this as hidden fields can be modified as its saved in the html on the client side.
No problem. Client can view the hidden field. But he can't make changes to that.
InvalidTypecast wrote: Can I simulate this in my codebehind in my aspx.cs file so that I don't have to worry about people messing with the values?
Simulating hidden fields ? How you are going to do this ? Creating hidden fields from code behind ?
|
|
|
|
|
Navaneeth. wrote: Client can view the hidden field. But he can't make changes to that.
Of course they can. Just view the source, edit it, save it as an html file on disk, and browse to it.
Navaneeth. wrote: Simulating hidden fields ? How you are going to do this ? Creating hidden fields from code behind ?
No. Just send the values as post data in a request.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: Of course they can. Just view the source, edit it, save it as an html file on disk, and browse to it.
Yes that they can do. But how come they can post the data to paypal ?
|
|
|
|
|
What do you mean?
---
single minded; short sighted; long gone;
|
|
|
|
|
I mean they can edit the values by saving to their computer. But they can't do anything with the values rite. Means sending that value to the server etc
|
|
|
|
|
Of course they can. If you have a form on a web page, the user's browser is sending the form to paypal, so there is no difference if they make their own form and send to paypal.
---
single minded; short sighted; long gone;
|
|
|
|
|
There are plugins now that actually make editing the html on a live page really easy. It's as simple as clicking an Edit HTML button and they can modify the live html and submit whatever they want.
How would I post the values from the code behind?
|
|
|
|
|
InvalidTypecast wrote: How would I post the values from the code behind?
Using a WebRequest or WebClient object.
---
single minded; short sighted; long gone;
|
|
|
|