|
The form tag missing from your code.
the RequiredFieldValidator must be inside the form tag
Like
Place your Html and valdation related code here
manojchilhate
|
|
|
|
|
|
hi
Looking for a bit of help. I have an asp.net listbox. I am wanting to manually be able to order the box by clicking a button. got everything set up but I keep getting an error saying that I can't have multiple selections on the list box when it is set as a single selection. I don't really know where I am going wrong so if anyone can help me I would most appreciate it. My code for the button click is as follows.
Protected Sub btOrderElementUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btOrderElementUp.Click<br />
If ltbOrderByList.Items.Count() = 0 Or ltbOrderByList.Items.Count() = 1 Then<br />
Exit Sub<br />
End If<br />
<br />
Dim liItem As ListItem<br />
Dim intItemIndex As Integer<br />
<br />
liItem = ltbOrderByList.SelectedItem<br />
intItemIndex = ltbOrderByList.SelectedIndex<br />
ltbOrderByList.Items.Insert(intItemIndex - 1, liItem)<br />
ltbOrderByList.Items.RemoveAt(intItemIndex)<br />
ltbOrderByList.ClearSelection()<br />
ltbOrderByList.SelectedIndex = intItemIndex - 1<br />
<br />
End Sub
The last two lines are my attempt to manually set the selected item so multiple items definitly aren't selected. If there is an easier way of doing this I would also appreciate it if you could tell me too!
Cheers
Ian
|
|
|
|
|
try this instead of
Senseicads wrote: ltbOrderByList.ClearSelection()
ltbOrderByList.SelectedIndex = intItemIndex - 1
ltbOrderByList.Items[ltbOrderByList.SelectedIndex].Selected = false;
ltbOrderByList.SelectedIndex = intItemIndex - 1
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
Thanks
I was able to just set the selected to true after my clearselection. Thanks for the help.
<br />
ltbOrderByList.ClearSelection()<br />
ltbOrderByList.Items(intItemIndex - 1).Selected = True
So is it not possible to use selectedIndex like I was attempting to then? The intellisense says that SelectedIndex is used to "get or set" the index of the selected item?
cheers
Ian
|
|
|
|
|
Hello To Everyone,
i want to declare a static variable in Asp.net which sholud also be a global variable.
Fr eg. i declared
static name as string
but when i declare it general section it gives me an error.
if i use public then i 'm unable to make it static variable
-- modified at 6:51 Monday 18th June, 2007
|
|
|
|
|
Create a static class
static MyClass
{
public static string _MyString;
}
you can access the above using the following:
String s = MyClass._MyString;
|
|
|
|
|
hello,
thanx but i need to code in vb..
could u help me out
|
|
|
|
|
In VB you can say "Shared" instead of "static".
|
|
|
|
|
|
Hi,
I'm toying around with an idea for a project but in order to get started I'd need to be able to access the HTML produced for an ASP.NET page from a function within that page.
Does anyone know if this is even possible - I was thinking if I wrote a custom http handler I might be able to do something along those lines....?
Cheers
Dave
|
|
|
|
|
Check for WebClient. Using this class you can get the HTML code for any webpage.
|
|
|
|
|
Is there any way you could render the page twice? Once to the output stream, once to a string variable?
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
Yes, you can do that by overriding Page.Render()[^]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
After a bit of playing about I've decided to go a slightly different route - instead I create a new Page object in memory add an HtmlForm and then add the (now customisable list of) controls from the original form to it. I can render in memory and retrieve the HTML using the <code<rendercontrol< code=""> method.
It caught me out at first but since I've added objects to a temporary page, they get removed from the original page at the same time! A quick <code>Dictionary<Control, int> to store the index they occupy on the original form lets me add them back across at the end.
HTH
Dave
|
|
|
|
|
I keep getting this error in an app that was working just before the weekend
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.
I've added a pages tag with the sessionstate set to true and i've referenced the hhtp module for the sessionstatemodule. I still can't get rid of this error.
I tries to reproduce the error or the changes needed to web.config so i created a new web app and added the following code to the default page
<pre>
if (Session.IsNewSession)
{
Session.Add("hereitis", "value");
}
</pre>
this runs without errors. Thinking that VS must have made some critical change to the config file before i ran it i looked in web.config but it still has only a few lines that aren't comments and none of them are the ones referenced in the error i get in my proper project. This leads me to believe that my problem does not lie with the web.config at all but i don't have any idea what might be causing it.
Has anyone seen or resolved this problem before?
Thanks,
Russell
|
|
|
|
|
Hi,
I am having some problem getting the value from the List Box which is the unique id for the name. It goes something like this. I got a table as this one.
tb_user
ID Name
11 John
12 Peter
13 Mike
So in the list box it will show only
Name
John
Peter
Mike
When I click on the button, it suppose to gather all the ID 1,2,3 to store it some where in the database.
I'd tried lstbox.SelectedValue[0] but this would cost it to retrieve '1' instead of '11', the first character of ID.
So my question is how can I retrieve all the IDs in my list box.
Thanks in advance.
J Liang
|
|
|
|
|
Liang,
you will have to store the Id in the list box as well. Try this:
listBox1.DataSource = somedatasource;
listBox1.DataTextField= "Name";
listBox1.DataValueField= "ID"
Now you can ask for listBox1.SelectedValue and you can get the ID for the item which is selected.
Hope that helps.
-- modified at 7:43 Monday 18th June, 2007
|
|
|
|
|
Hi RepliCrux,
Thanks for the reply.
It seems that I could not find DataTextField and DataValueField when I do listBox1.xxx. Did I missed out something?
This is what I am doing to populate the other listbox
ListItemCollection myCollection = new ListItemCollection();
for (int count = 0; count < mySource.Items.Count; count++)
{
if (mySource.Items[count].Selected == true)
{
myCollection.Add(aSource.Items[count]);
}
}
for (int count = 0; count < myCollection.Count; count++)
{
mySource.Items.Remove(myCollection[count]);
myTarget.Items.Add(myCollection[count]);
}
So when I do myTarget.DataTextField, I can't find the .DataTextField
J Liang
|
|
|
|
|
Hi Liang,
If you are using windows forms you will get the properties as:
mySource.DisplayMember = "Name" ;
mySource.ValueMember = "ID";
DataTextField and DataValueField are for web.
If this does not work send me the code where you are populating the listbox.
Cheers,
|
|
|
|
|
Hi RepliCrux,
Actually I got the function code from Mankayarkarasi (http://www.codeproject.com/aspnet/MCEnhancedListBoxControl.asp[^]
It is like this:
private void AddRemoveItem(ListBox aSource, ListBox aTarget)
{
ListItemCollection licCollection;
try
{
licCollection = new ListItemCollection();
for (int intCount = 0; intCount < aSource.Items.Count; intCount++)
{
if (aSource.Items[intCount].Selected == true)
{
licCollection.Add(aSource.Items[intCount]);
}
}
for (int intCount = 0; intCount < licCollection.Count; intCount++)
{
aSource.Items.Remove(licCollection[intCount]);
aTarget.Items.Add(licCollection[intCount]);
}
}
catch (Exception expException)
{
this.jscript.MsgBox(expException.Message);
}
finally
{
licCollection = null;
}
}
Then from the button to populate, I do this:
protected void btnAssignOne_Click(object sender, EventArgs e)
{
//lstFromUser and lstToUser is ListItem from the listbox
this.AddRemoveItem(this.lstFromUser, this.lstToUser);
}
Then when I click another button, it suppose to gather all the IDs from this.lstToUser and that's where it doesn't work for me.
I suspect the ID did transfer to the this.lstToUser. When I do this.lstToUser.SelectedValue.ToString(), I could get the ID but only the first one. I thought of using this.lstToUser.SelectedValue[0].ToString() but it was not the correct way.
J Liang
|
|
|
|
|
Liang,
I think you are using database to retreive the values. In the article you hae mentioned please have a look at the section "Points Of Interest"
The data in the example is created on the fly. you don't want that. If you want the ID of the table you will need to bind that using binding proprty of the ListBox, as I mentioned earlier and mentioned in the article you have mentioned.
Cheers.
|
|
|
|
|
Liang, have a look at the section "Points Of Interest" (the article you are refering). It is mentioned that if you want to connect to the database you will have to use Databinding.
If you want the ID of the Item, you will have to use the way I mentioned earlier. In the section "Points Of Interest", its specified.
Cheers,
|
|
|
|
|
Hi RepliCrux,
Been quite busy lately, only now I remember to put a reply here.
I got it working though, it seems the way the article said, the ID is already in the listbox, so when I pass the item to another listbox, the ID is already there and here is how I capture all the ID.
for (int i = 0; i < this.lstToUser.Items.Count; i++)
{
if (this.lstToUser.Items[i].Selected == false)
{
this.lstToUser.Items[i].Selected = true;
userlist.Add(this.lstToUser.SelectedValue);
this.lstToUser.Items[i].Selected = false;
}
else
{
userlist.Add(this.lstToUser.SelectedValue);
this.lstToUser.Items[i].Selected = false;
}
}
By giving a command to the list box to select one by one every item in the list and add it into the list item by using this.lstToUser.SelectedValue since the value is suppose to be holding the IDs, then I'll deselect it and select the next one.
But before this we need to do
for (int i = 0; i < this.lstToUser.Items.Count; i++)
{
this.lstToUser.Items[i].Selected = false;
}
To deselect everything in the list box before starting to capture the ID.
This might look strange but at least it works for the mean time
J Liang
|
|
|
|
|
i want to open javascript function in codebehind .
but it open on cell_click event.
pls help me urgently.
gayatri
Gayatri
|
|
|
|