Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Thursday, March 29, 2012

Pop Up Window with Server.Transfer

Hi,

In one of my asp.net page, when users click on a button, I am using Server.Transfer to redirect user to another page and pass all the info to that page asServer.Transfer("TripDetails.aspx").

I need to open a new window and pass all the info to new page. How can I achive this? How can I open a new window and useServer.Transfer at the same time?

Thanks

On the click event of the button you'll need to open a new window there using javascript like window.open. If the button is submitting a form you can set the TARGET of the FORM to be _blank;

<FORM target="_blank" action="...">


Thanks Aidy, it works for me.

Pop Up without TitleBars?

Hello All!
I have been trying to customize pop up windows for my ASP.NET Page. I want
to have a custom title bar. Is there a way to remove the windows title bar
from the pop up and make it apear as a frameless window?
Also I am using Windows XP with SP1.
If you know a way out, please help me!
Regards
Jyoti> Hello All!
> I have been trying to customize pop up windows for my ASP.NET Page. I want
to
> have a custom title bar. Is there a way to remove the windows title bar fr
om
> the pop up and make it apear as a frameless window?
> Also I am using Windows XP with SP1.
> If you know a way out, please help me!
> Regards
> Jyoti
I don't think that is possible, mainly for security reasons.
The fact that *you* are using a particular platform is not important
here, you will need to know what your *visitors* are using.
Hans Kesting
Thanks for replying Hans!
The point is that my application should work for the visitors using Windows
XP! And its not working there! Well, I am still trying to find a way out.
Thanks for your help!
Regards Jyoti
"Hans Kesting" <news.1.hansdk@.spamgourmet.com> wrote in message
news:mn.724c7d5b866fd633.41829@.spamgourmet.com...
> I don't think that is possible, mainly for security reasons.
> The fact that *you* are using a particular platform is not important here,
> you will need to know what your *visitors* are using.
> Hans Kesting
>

Pop Up without TitleBars?

Hello All!

I have been trying to customize pop up windows for my ASP.NET Page. I want
to have a custom title bar. Is there a way to remove the windows title bar
from the pop up and make it apear as a frameless window?

Also I am using Windows XP with SP1.
If you know a way out, please help me!

Regards
Jyoti> Hello All!
> I have been trying to customize pop up windows for my ASP.NET Page. I want to
> have a custom title bar. Is there a way to remove the windows title bar from
> the pop up and make it apear as a frameless window?
> Also I am using Windows XP with SP1.
> If you know a way out, please help me!
> Regards
> Jyoti

I don't think that is possible, mainly for security reasons.

The fact that *you* are using a particular platform is not important
here, you will need to know what your *visitors* are using.

Hans Kesting
Thanks for replying Hans!

The point is that my application should work for the visitors using Windows
XP! And its not working there! Well, I am still trying to find a way out.
Thanks for your help!

Regards Jyoti

"Hans Kesting" <news.1.hansdk@.spamgourmet.com> wrote in message
news:mn.724c7d5b866fd633.41829@.spamgourmet.com...
>> Hello All!
>>
>> I have been trying to customize pop up windows for my ASP.NET Page. I
>> want to have a custom title bar. Is there a way to remove the windows
>> title bar from the pop up and make it apear as a frameless window?
>>
>> Also I am using Windows XP with SP1.
>> If you know a way out, please help me!
>>
>> Regards
>> Jyoti
> I don't think that is possible, mainly for security reasons.
> The fact that *you* are using a particular platform is not important here,
> you will need to know what your *visitors* are using.
> Hans Kesting

Pop up with AJAX enable page

help pls. I just add the Ajax tools on my page and now my pop up code is not working.
Page.ClientScript.RegisterStartupScript(Me.GetType, "myscript", "<script Language='JavaScript'>alert('" + x + "');</script>")
tnxPage.Clientscript.RegisterStartupScript(me,"scriptAlert","alert('test');",True);

Look at the last parameter.
Page.Clientscript.RegisterStartupScript(me,"scriptAlert","alert('test');",True)

error on "me" - cannot be converted to 'system.type'

any other solution pls... tnx
Sorry, my bad.

Page.ClientScript.RegisterStartupScript(Me.GetType, "scriptAlert", "alert('test');", True)
Sorry, my bad.

Page.ClientScript.RegisterStartupScript(Me.GetType, "scriptAlert", "alert('test');", True)

:D it's me again. ive tried your code but still no pop up message :(. this code works if you dont have Ajax updatepanel but in my case i used AJAX Updatepanel. any help pls.

tnx
Does this help?

http://www.asp.net/AJAX/Documentation/Live/tutorials/CustomizingErrorHandlingforUpdatePanel.aspx
Does this help?

http://www.asp.net/AJAX/Documentation/Live/tutorials/CustomizingErrorHandlingforUpdatePanel.aspx

yes it helpz. tnx to all

pop up windows with img and text from...?

using vb.net, with sql 2000 personal edition.

I'm trying to create a portfolio page, the pages would be divided into years from 2001 ~ 2004 with each page a link of projects that my company has done. when the link is clicked it would open a new window with both image and text.

my question is how should i build this pop up page, with over 90 images i do not want to create individual aspx pop up windows, so if i was to get img and text info where should it be coming from? would sql server or is there was a to put this info in the project page? I haven't a clue, plz help.

ps. if you can point me to an example on the net that would be great..

focusA good place to start may be the following tutorial:
A Robust Image Gallery for ASP.NET
wow thanks NewKid2~

i'm still reading it but its a great example, not only for my project but for my personal use as well, also i love the fact that its in vb.net there should be a page called top 10 everyday examples in vb.net for the noobie in you!

focus
> there should be a page called top 10 everyday examples in vb.net

Well, the same guys have written a bunch of ASP.NET articles, most of them using VB.NET, and all written in an easy-to-understand way.

You can see the entire list of their articles here:
http://aspnet.4guysfromrolla.com

Pop Up/Refresh Issue

I have a parent page that contains a datagrid. On this page is a link to "Add New" record. I have done this by opening a child/pop up so they can enter the data in a new window. When the user submits, the parent page reloads and refreshes the data. Here is the code in the child page:

btnAdd.Attributes.Add("onclick", "window.opener.location.reload();");

I kinda have two problems here, one I can live with...for now.

Problem 1: When the page reloads, the user has to click "Retry". This works, but is a bit sloppy. I've searched a few different methods on this forum, but none seem to submit and refresh my data. (I can't simply refresh because I have a few panels on the parent that throw a wrench into it)

Problem 2: The line that I posted earlier is fine, and works well; however I do have some validation (server side) on the child form. If the validation in the btnAdd_Click event isn't a success, I would like to avoid reloading the parent. How would I go about doing that?

Thanks.

Just to clarify a bit, I want to check a condition before I have my js reload the parent page.

Let's say:

If (someCondition)

{

//reload parent page

}

else

{

// don't reload parent page

}

Any suggestions?


Instead of spamming the forum with much of the same problem, I'll add to this one.

I would also like to somehow clear the last submmited button on the parent from the child. Let me try to explain.

On the parent the user may press a button which kicks off validation on the server. If validation on the server fails, a message on the page is displayed. (Parent) Now, if the user decides to add a record at this time via the pop up or child, hitting update on the child will reload the parent page; however, in this case my grid on the parent won't refresh because it's executing the submit on the parent. Therefore displaying "validation failed", when in fact it didn't.

Eh, I know this probably sounds messy, but if someone can help with this or any of my other pop up/refresh problems in this thread, I would appreciate it.


I don't know of this is going to help you or not but here is my 2cents. On the child pop up page when the user submits the informationyou can send a value of true to the parent which will represent thatthe child form has been submitted. This value can be send usingQueryString or Session State. When the parent page recieves thisinformation it can referesh it.
Does that help ?

Poping up a window AND redirecting the page thtat triggered the po

Hi to all. I'm having trouble with the following situation:
I have a page where the user inserts some stuff and when he clicks on the
submit button a popup window showing that info is launched and the page "A"
where he was is redirected to another page, page "B". This page "B" can also
be accessed by other means. Can this be done? If so, how?
I was trying to do this:
protected void button_Click(object sender, EventArgs e)
{
string popupScript = String.Format("<script language='javascript'>" +
"window.open('ShowReport.ashx','CustomPopUp'," +
"'width=600, height=500, menubar=no, resizable=yes,
toolbar=no,
location=no, statusbar=no, left=212, top=184')</script>");
Page.RegisterStartupScript("ShowReport", popupScript);
Page.Response.Redirect("NewPage.aspx");
}
But what happens is that I get imediatly redirected to the NewPage.aspx. If
I'm not wrong, this happens because the current page isn't reloaded after
this event is treated. What I am asking is, for the effect I want (both the
pop-up and the redirect occurs) what can I do? I have also thought on trying
to open the pop-up on the loading of NewPage.aspx, by passing some specific
value when I make the redirect (something like
Response.Redirect("NewPage.aspx?popup=yes").
Any ideas/sugestions?
Thanks in advanceHi Ricardo,
The popup window must be generated on the client. This means that the page
must be loaded to generate the popup. What you can do is to have the page
pop up a window, and then submit back to the server, where the Redirect can
occur.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"Ricardo Videira" <RicardoVideira@.discussions.microsoft.com> wrote in
message news:2ABEC8F1-C366-4934-BE57-01641826EA8F@.microsoft.com...
> Hi to all. I'm having trouble with the following situation:
> I have a page where the user inserts some stuff and when he clicks on the
> submit button a popup window showing that info is launched and the page
> "A"
> where he was is redirected to another page, page "B". This page "B" can
> also
> be accessed by other means. Can this be done? If so, how?
> I was trying to do this:
> protected void button_Click(object sender, EventArgs e)
> {
> string popupScript = String.Format("<script
> language='javascript'>" +
> "window.open('ShowReport.ashx','CustomPopUp'," +
> "'width=600, height=500, menubar=no, resizable=yes,
> toolbar=no,
> location=no, statusbar=no, left=212, top=184')</script>");
> Page.RegisterStartupScript("ShowReport", popupScript);
> Page.Response.Redirect("NewPage.aspx");
> }
>
> But what happens is that I get imediatly redirected to the NewPage.aspx.
> If
> I'm not wrong, this happens because the current page isn't reloaded after
> this event is treated. What I am asking is, for the effect I want (both
> the
> pop-up and the redirect occurs) what can I do? I have also thought on
> trying
> to open the pop-up on the loading of NewPage.aspx, by passing some
> specific
> value when I make the redirect (something like
> Response.Redirect("NewPage.aspx?popup=yes").
> Any ideas/sugestions?
> Thanks in advance
>
if a page has a redirect header (produced by calling Redirect), the browser
will not render the html, if you want the html rendered, you need to use a
meta tag with a refresh. also popup blocks will prevent you popup window
anyway. you should change the button to a html hyperlink that opens the
report.
-- bruce (sqlwork.com)
"Ricardo Videira" <RicardoVideira@.discussions.microsoft.com> wrote in
message news:2ABEC8F1-C366-4934-BE57-01641826EA8F@.microsoft.com...
> Hi to all. I'm having trouble with the following situation:
> I have a page where the user inserts some stuff and when he clicks on the
> submit button a popup window showing that info is launched and the page
> "A"
> where he was is redirected to another page, page "B". This page "B" can
> also
> be accessed by other means. Can this be done? If so, how?
> I was trying to do this:
> protected void button_Click(object sender, EventArgs e)
> {
> string popupScript = String.Format("<script
> language='javascript'>" +
> "window.open('ShowReport.ashx','CustomPopUp'," +
> "'width=600, height=500, menubar=no, resizable=yes,
> toolbar=no,
> location=no, statusbar=no, left=212, top=184')</script>");
> Page.RegisterStartupScript("ShowReport", popupScript);
> Page.Response.Redirect("NewPage.aspx");
> }
>
> But what happens is that I get imediatly redirected to the NewPage.aspx.
> If
> I'm not wrong, this happens because the current page isn't reloaded after
> this event is treated. What I am asking is, for the effect I want (both
> the
> pop-up and the redirect occurs) what can I do? I have also thought on
> trying
> to open the pop-up on the loading of NewPage.aspx, by passing some
> specific
> value when I make the redirect (something like
> Response.Redirect("NewPage.aspx?popup=yes").
> Any ideas/sugestions?
> Thanks in advance
>

Popping up a window

Hi,

I'm writing a page in asp.net to post something to a website and I'm trying to add a preview button to the page. The problem with the code lies in popping up a window containing the preview. The onClick event of the asp:button runs a subroutine to create a new text file, 'temp.txt' (using a Try... Catch statement). Once this is done, I have added the following line:
message.Text = "<script language=Javascript>window.open('disp_report.asp?temp.txt');</script>", where message is an asp:label. This results in a Compilation Error saying 'Try statement must end with an 'End Try', almost as if the line of code was an unterminated string. Commenting out the line (with a ') results in the same error.

Any ideas?Can you post your code as you have it in the IDE?
How much do you want? The whole page?
Here's the page (attached). The line of code I mentioned is commented out at the bottom of the Preview_Click subroutine. It still causes the error, though. For the moment, I've got the message label showing a hyperlink to view the preview, which is a bit messy, but works.
I cant get the attachment, says invalid. Can you make it a textfile?
Done before you posted ;)
Ah, ok. I was getting the forums source for this page :lol:
Let me see what you got now.
I edited the post with the aspx attachment, removed that and added the text file instead.
Don't set the label's text to that script.

To popup a window, in the button's click event, after generating the file, do this:

Page.RegisterStartupScript("script1","<script language=Javascript>window.open('disp_report.asp?temp.txt');</script>")

That is the way to do it.
Thanks for helping froggy. I was stuck on this.

I fed you earlier so you'll have to wait for the next mealtime. :D
In case you haven't noticed by now, I like microwaved cheese sandwiches :afrog:
Thanks for that.

How do I then remove the Startup script so that it doesn't fire again when they click Save?
No, that hasn't worked... still giving me the same error.

Putting it outside of the Try statement throws up:
'BC30648: String constants must end with a double quote.'

And the calendar control keeps going Italian on me!
Okay, building up the string gradually has shown that the problem seems to be with the final ">". However,
Dim strScript As String
strScript = "<script language=Javascript>window.open('disp_report.asp?temp.txt');</script" & ">"
Page.RegisterStartupScript("script1", strScript) seems to work.

Weird...

This still isn't giving me a popup, either. Searching the page source after the button has been clicked shows that the script is there, right after the 'Temporary match report created...' on the page. Any more ideas?

**Edit**

Turns out, the popup works fine - Norton Internet Security is just blocking it! Any way round this? I'm still having the Italian calendar problem, too.
Any popup blockers in place?
Norton Internet Security is the culprit. Is there any way round this? I can add an exception on my computer, but it's not really feasible for everyone visiting using Norton to do.

I'm still getting the Italian calendar from time to time, too!
For the first part, do you really need the popup to open when the page reloads, or can you have it when the user clicks on the link? Things could be easier if it's on the link click.

For the second part, how Italian is it? Is it romancing you?
Well, it would look better if the page popped up, but it's not essential.

As for the calendar, I've attached an image.
Oh, it's going Italian on you, literally.

I thought you were using a cliche or euphemism for "It's trying to kill me." :sick:

For the calendar, check your regional settings in Control Panel.
My regional settings are fine. It's just bizarre that the calendar control is only sometimes Italian... It's something like 1 time in 5 that it appears like that!

**Edit**

The following lines of code seem to have fixed it:

Sub Page_Load()
Dim lang As System.Globalization.CultureInfo
lang = New System.Globalization.CultureInfo("en-gb")
System.Threading.Thread.CurrentThread.CurrentCulture = lang
System.Threading.Thread.CurrentThread.CurrentUICulture = lang
End Sub

Back to the original question - can you think of a reason why I had to concatenate on the last '>' like that?
No, I can't think of any. You shouldn't even have to do that. It maybe a simple double quote problem that we're overlooking.
Dont you need to use the escape char when using the "/"?
Not for asp.net, surely? It should treat everything within the quotation marks as a string literal and that's it...
The escape characters would be in use in C# codebehind, but he's got VB.NET there.
Dont you need the escpae char for the JavaScript is what I was meaning.
If it were in the javascript code itself, yes. :D
Well, I suppose I should mark this resolved. We got the popup going, although no resolution about that last '>'. I've actually seen that in some code before - where it's added on at the end, but there was no explanation as to why. I just thought, 'that looks pointless...' and left it at that.

Populate 2nd dropdown list based on selecteditem in first with out postback?

Hi All:

I have an aspx page that has 2 dropdownlists. I want to populate the second
dropdownlist based on the selecteditem in the first dropdown. I know I can
do this by doing a post back and using the selectedindex and loading the
second dropdownlist.

Is there anyway I can do this without doing a postback? Any ideas/pointers
will be much appreciated.

Thanks!

VinayYou'll have to use JavaScript in the client.

search: dependent listbox

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

"Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
> Hi All:
> I have an aspx page that has 2 dropdownlists. I want to populate the
> second dropdownlist based on the selecteditem in the first dropdown. I
> know I can do this by doing a post back and using the selectedindex and
> loading the second dropdownlist.
> Is there anyway I can do this without doing a postback? Any ideas/pointers
> will be much appreciated.
> Thanks!
> Vinay
Thanks for the pointer - will do some reading and see if I can implement it.

"clintonG" <csgallagher@.REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:ek$zp%234oFHA.3656@.TK2MSFTNGP09.phx.gbl...
> You'll have to use JavaScript in the client.
> search: dependent listbox
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
> "Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
> news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
>> Hi All:
>>
>> I have an aspx page that has 2 dropdownlists. I want to populate the
>> second dropdownlist based on the selecteditem in the first dropdown. I
>> know I can do this by doing a post back and using the selectedindex and
>> loading the second dropdownlist.
>>
>> Is there anyway I can do this without doing a postback? Any
>> ideas/pointers will be much appreciated.
>>
>> Thanks!
>>
>> Vinay
>>

Populate 2nd dropdown list based on selecteditem in first with out postback?

Hi All:
I have an aspx page that has 2 dropdownlists. I want to populate the second
dropdownlist based on the selecteditem in the first dropdown. I know I can
do this by doing a post back and using the selectedindex and loading the
second dropdownlist.
Is there anyway I can do this without doing a postback? Any ideas/pointers
will be much appreciated.
Thanks!
VinayYou'll have to use JavaScript in the client.
search: dependent listbox
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
> Hi All:
> I have an aspx page that has 2 dropdownlists. I want to populate the
> second dropdownlist based on the selecteditem in the first dropdown. I
> know I can do this by doing a post back and using the selectedindex and
> loading the second dropdownlist.
> Is there anyway I can do this without doing a postback? Any ideas/pointers
> will be much appreciated.
> Thanks!
> Vinay
>
Thanks for the pointer - will do some reading and see if I can implement it.
"clintonG" < csgallagher@.REMOVETHISTEXTmetromilwaukee
.com> wrote in message
news:ek$zp%234oFHA.3656@.TK2MSFTNGP09.phx.gbl...
> You'll have to use JavaScript in the client.
> search: dependent listbox
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
> "Vinay" <vinay_hs_removethis@.nospam.yahoo.com> wrote in message
> news:ef$cOw4oFHA.2976@.TK2MSFTNGP12.phx.gbl...
>

Monday, March 26, 2012

Populate a Drop Down List

Hello,

i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists.
Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
DAY, MONTH, and YEAR.

I don't want to insert the values and text to each drop down list.

So i want to create a script that populates a certain Drop Down List with
certain values when page loads such as:

Day: 1,2,3,4,5,...
Month: January, February, ..., December
Year: 2004, 2003, 2002, 2001, ...

This way in that script i will be able to control how all the Drop Down
Lists are populated just bu changing the script.

Can you help me out?

Thank You,
Miguel

P.S: I am working with ASP.NET / VB.First thing is to remove the word "script" from your vocabulary. VB .NET is
not VBScript.

You could write some code in the .aspx.vb (code-behind) Page_Load event that
will populate the drop down lists by determining today's date (now) and then
use the various methods of the now value to extract the day, month and year.
Then, via looping, you can build up the items on the lists.

"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
Create a ListItem. Set the value and the text properties and then add it to
the drop down list. I'm not sure about VB.Net but in C# it would be
something like this:

using System.Globalization;

dtfi = new DateTimeFormatInfo();
for (int month = 1; month < 13; month ++)
{
ListItem li = new ListItem();
li.Text = dtfi.GetMonthName(month);
li.Value = month;
ddlMonth.Items.Add(li);
}

Do basically the same thing for each drop down list. Translating the C# to
VB should be pretty straight forward.

Hope this helps,

Dale

"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
One obvious error in my code, make 2nd line:

DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

But then, you have to convert the concept into VB.Net anyway, so it probably
didn't throw you too much.

Good luck

Dale

"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:uyIxbbCUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Create a ListItem. Set the value and the text properties and then add it
to
> the drop down list. I'm not sure about VB.Net but in C# it would be
> something like this:
> using System.Globalization;
> dtfi = new DateTimeFormatInfo();
> for (int month = 1; month < 13; month ++)
> {
> ListItem li = new ListItem();
> li.Text = dtfi.GetMonthName(month);
> li.Value = month;
> ddlMonth.Items.Add(li);
> }
> Do basically the same thing for each drop down list. Translating the C#
to
> VB should be pretty straight forward.
> Hope this helps,
> Dale
>
> "Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
> news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> > Hello,
> > i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
> Lists.
> > Each group of Drop Down Lists include 3 Drop Down Lists for date such
as:
> > DAY, MONTH, and YEAR.
> > I don't want to insert the values and text to each drop down list.
> > So i want to create a script that populates a certain Drop Down List
with
> > certain values when page loads such as:
> > Day: 1,2,3,4,5,...
> > Month: January, February, ..., December
> > Year: 2004, 2003, 2002, 2001, ...
> > This way in that script i will be able to control how all the Drop Down
> > Lists are populated just bu changing the script.
> > Can you help me out?
> > Thank You,
> > Miguel
> > P.S: I am working with ASP.NET / VB.

Populate a dropdown list with a variable from a Querystring

Hi,

I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the querystring but I'm not sure
how to pass that value. I get the error that IntCourseID is not declared in:

<asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
DataSource="<%# GetLessons(IntCourseID) %>"

I tried moving the querystring outside the page load but that didn't work:

This is the code I have:

<%@dotnet.itags.org. Page Language="VB" Debug="true" validaterequest="false" %
<script runat="server"
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack = False Then
Dim IntCourseID as Integer
IntCourseID = Request.QueryString( "CourseID" )

End If
End Sub

Function GetLessons(ByVal courseID As Integer) As
System.Data.IDataReader
Dim connectionString As String = "server='(local)';
trusted_connection=true; database='xx'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)

Dim queryString As String = "SELECT [tblLesson].[LessonID],
[tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
"[tblLesson].[CourseID] = @dotnet.itags.org.CourseID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_courseID As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseID.ParameterName = "@dotnet.itags.org.CourseID"
dbParam_courseID.Value = courseID
dbParam_courseID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseID)

dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

Return dataReader
End Function

Sub addButton_Click(sender As Object, e As EventArgs)
Response.Redirect("selectPage.aspx")
End Sub

</script>
<html>
<head>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:DropDownList id="fLessonID" runat="server"
DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
DataTextField="LessonTitle"></asp:DropDownList>
<asp:Button id="addButton" onclick="addButton_Click" runat="server"
Text="Next"></asp:Button
</form>
</body>
</html
Thanks for any help

--
Message posted via http://www.dotnetmonster.comHi Jim,

I understood your probleim in the following way after reading your code...

You have a Integer Variable (IntCourseID) in your code behind fi.e...and you
want to use that value in your .aspx page. Am I right...?

If I'm right...then solution for your problem is...

Have a hidden control...and assign your querystring value (CourseId) to the
value of the hidden control. Now you can use that control in your .aspx page
code, to bind with the ddl.

Cheers,

Jerome. M

"Jim via DotNetMonster.com" wrote:

> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not sure
> how to pass that value. I get the error that IntCourseID is not declared in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click" runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.dotnetmonster.com
Hello
Dear Jim!
First the problem with your code is that you are declaring a Variable in
pageload event "IntCourseID" that will be destroyed when this event will
reach its end.
First Declare this variable in the GetLessons function
IntCourseID = Request.QueryString( "CourseID" )
so that this variable with its value can be accessed.

Regards
Malik Asif
ASP.NET,VB.NET

"Jim via DotNetMonster.com" <forum@.DotNetMonster.com> wrote in message
news:8596ac9543c84e2e8aad88fcc163c277@.DotNetMonste r.com...
> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not
sure
> how to pass that value. I get the error that IntCourseID is not declared
in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionStri ng)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click"
runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.dotnetmonster.com

Populate A Dropdown From Another Dropdown

I have a page that has two dropdowns on it. When the page loads, the first box is populated from an Access table. Here's the tricky part for me...

(Just when I think I understand how "postback" works, I find I'm wrong again!)

I have the dropdown set to autopostback=true. When the user selects a choice in this dropdown, the page postsback (I think) and I want it to then query another table in the same database to fill the second dropdown list AND keep the original dropdown list's selection.

For some reason, I can get it to fill the original dropdown, but then when it postsback, I get an error because my SQL statement to load the second dropdown looks like this:

Dim objSeriesDA As New OleDb.OleDbDataAdapter("SELECT * FROM Series WHERE fldProviderID=" & lstProvider.SelectedItem.Value & " ORDER BY fldSeriesNumber DESC", objSeriesCN)

Apparently, when the page postsback, the original dropdown list loses its selection, causing the SQL statement above to error out on a null reference.

Any ideas?

If need be, I can throw this up on a server so you all can see what I'm talking about... I can post the full source as well.

Thanks!

HWKY
:)wrap the code that is filling your first drop down list with this:

If Not Page.IsPostBack Then
'...your code here.
End If
Does anyone have a link to some information that explains PostBack in depth?
well, this link (http://www.15seconds.com/Issue/020102.htm) helped me with some basics on the page lifecycle when i was having user control postback problems. Really, there's not much more to the kind of postback stuff in your first post. If you know how the page loads and when control events are evaluated, that's pretty much it. Were you looking for information on how to roll your own PostBack handler or something else?

Populate a Drop Down List

Hello,
i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists.
Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
DAY, MONTH, and YEAR.
I don't want to insert the values and text to each drop down list.
So i want to create a script that populates a certain Drop Down List with
certain values when page loads such as:
Day: 1,2,3,4,5,...
Month: January, February, ..., December
Year: 2004, 2003, 2002, 2001, ...
This way in that script i will be able to control how all the Drop Down
Lists are populated just bu changing the script.
Can you help me out?
Thank You,
Miguel
P.S: I am working with ASP.NET / VB.First thing is to remove the word "script" from your vocabulary. VB .NET is
not VBScript.
You could write some code in the .aspx.vb (code-behind) Page_Load event that
will populate the drop down lists by determining today's date (now) and then
use the various methods of the now value to extract the day, month and year.
Then, via looping, you can build up the items on the lists.
"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
>
Create a ListItem. Set the value and the text properties and then add it to
the drop down list. I'm not sure about VB.Net but in C# it would be
something like this:
using System.Globalization;
dtfi = new DateTimeFormatInfo();
for (int month = 1; month < 13; month ++)
{
ListItem li = new ListItem();
li.Text = dtfi.GetMonthName(month);
li.Value = month;
ddlMonth.Items.Add(li);
}
Do basically the same thing for each drop down list. Translating the C# to
VB should be pretty straight forward.
Hope this helps,
Dale
"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
>
One obvious error in my code, make 2nd line:
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
But then, you have to convert the concept into VB.Net anyway, so it probably
didn't throw you too much.
Good luck
Dale
"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:uyIxbbCUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Create a ListItem. Set the value and the text properties and then add it
to
> the drop down list. I'm not sure about VB.Net but in C# it would be
> something like this:
> using System.Globalization;
> dtfi = new DateTimeFormatInfo();
> for (int month = 1; month < 13; month ++)
> {
> ListItem li = new ListItem();
> li.Text = dtfi.GetMonthName(month);
> li.Value = month;
> ddlMonth.Items.Add(li);
> }
> Do basically the same thing for each drop down list. Translating the C#
to
> VB should be pretty straight forward.
> Hope this helps,
> Dale
>
> "Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
> news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Lists.
as:
with
>

Populate a dropdown list with a variable from a Querystring

Hi,
I'm passing a variable to another page through a querystring. I then want
to use that variable to retrieve records from a database to poulate a
dropdownlist. I can read the variable from the querystring but I'm not sure
how to pass that value. I get the error that IntCourseID is not declared in:
<asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
DataSource="<%# GetLessons(IntCourseID) %>"
I tried moving the querystring outside the page load but that didn't work:
This is the code I have:
<%@dotnet.itags.org. Page Language="VB" Debug="true" validaterequest="false" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Page.IsPostBack = False Then
Dim IntCourseID as Integer
IntCourseID = Request.QueryString( "CourseID" )
End If
End Sub
Function GetLessons(ByVal courseID As Integer) As
System.Data.IDataReader
Dim connectionString As String = "server='(local)';
trusted_connection=true; database='xx'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [tblLesson].[LessonID],
[tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
"[tblLesson].[CourseID] = @dotnet.itags.org.CourseID)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_courseID As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseID.ParameterName = "@dotnet.itags.org.CourseID"
dbParam_courseID.Value = courseID
dbParam_courseID.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseID)
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
Sub addButton_Click(sender As Object, e As EventArgs)
Response.Redirect("selectPage.aspx")
End Sub
</script>
<html>
<head>
</head>
<body leftmargin="0" topmargin="0">
<form runat="server">
<asp:DropDownList id="fLessonID" runat="server"
DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
DataTextField="LessonTitle"></asp:DropDownList>
<asp:Button id="addButton" onclick="addButton_Click" runat="server"
Text="Next"></asp:Button>
</form>
</body>
</html>
Thanks for any help
Message posted via http://www.webservertalk.comHi Jim,
I understood your probleim in the following way after reading your code...
You have a Integer Variable (IntCourseID) in your code behind fi.e...and you
want to use that value in your .aspx page. Am I right...?
If I'm right...then solution for your problem is...
Have a hidden control...and assign your querystring value (CourseId) to the
value of the hidden control. Now you can use that control in your .aspx page
code, to bind with the ddl.
Cheers,
Jerome. M
"Jim via webservertalk.com" wrote:

> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not sur
e
> how to pass that value. I get the error that IntCourseID is not declared i
n:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionString)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click" runat="server
"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.webservertalk.com
>
Hello
Dear Jim!
First the problem with your code is that you are declaring a Variable in
pageload event "IntCourseID" that will be destroyed when this event will
reach its end.
First Declare this variable in the GetLessons function
IntCourseID = Request.QueryString( "CourseID" )
so that this variable with its value can be accessed.
Regards
Malik Asif
ASP.NET,VB.NET
"Jim via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:8596ac9543c84e2e8aad88fcc163c277@.Do
webservertalk.com...
> Hi,
> I'm passing a variable to another page through a querystring. I then want
> to use that variable to retrieve records from a database to poulate a
> dropdownlist. I can read the variable from the querystring but I'm not
sure
> how to pass that value. I get the error that IntCourseID is not declared
in:
> <asp:DropDownList id="fLessonID" runat="server" DataValueField="LessonID"
> DataSource="<%# GetLessons(IntCourseID) %>"
> I tried moving the querystring outside the page load but that didn't work:
> This is the code I have:
> <%@. Page Language="VB" Debug="true" validaterequest="false" %>
> <script runat="server">
> Sub Page_Load(sender As Object, e As EventArgs)
> If Page.IsPostBack = False Then
> Dim IntCourseID as Integer
> IntCourseID = Request.QueryString( "CourseID" )
> End If
> End Sub
>
> Function GetLessons(ByVal courseID As Integer) As
> System.Data.IDataReader
> Dim connectionString As String = "server='(local)';
> trusted_connection=true; database='xx'"
> Dim dbConnection As System.Data.IDbConnection = New
> System.Data.SqlClient.SqlConnection(connectionString)
> Dim queryString As String = "SELECT [tblLesson].[LessonID],
> [tblLesson].[LessonTitle] FROM [tblLesson] WHERE ("& _
> "[tblLesson].[CourseID] = @.CourseID)"
> Dim dbCommand As System.Data.IDbCommand = New
> System.Data.SqlClient.SqlCommand
> dbCommand.CommandText = queryString
> dbCommand.Connection = dbConnection
> Dim dbParam_courseID As System.Data.IDataParameter = New
> System.Data.SqlClient.SqlParameter
> dbParam_courseID.ParameterName = "@.CourseID"
> dbParam_courseID.Value = courseID
> dbParam_courseID.DbType = System.Data.DbType.Int32
> dbCommand.Parameters.Add(dbParam_courseID)
> dbConnection.Open
> Dim dataReader As System.Data.IDataReader =
> dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
> Return dataReader
> End Function
> Sub addButton_Click(sender As Object, e As EventArgs)
> Response.Redirect("selectPage.aspx")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body leftmargin="0" topmargin="0">
> <form runat="server">
> <asp:DropDownList id="fLessonID" runat="server"
> DataValueField="LessonID" DataSource="<%# GetLessons(IntCourseID) %>"
> DataTextField="LessonTitle"></asp:DropDownList>
> <asp:Button id="addButton" onclick="addButton_Click"
runat="server"
> Text="Next"></asp:Button>
> </form>
> </body>
> </html>
> Thanks for any help
> --
> Message posted via http://www.webservertalk.com

Populate a Listbox by using JavaScript

Hi,
I have a page with a ListBox on it, and It's also have a some buttons to
populate the ListBox by using JavaScript.
I have no problem with populate the listbox using JavaScript. But when the
page is submited / postback, the listbox is still empty.
Do you have any solution for this case (if I still want to use ListBox
Server Control) ?
thanks,
Devin WoodDevin,
You need to pass the new items to the server. It can be done in a hidden
input html control. On server side you will parse the input's value and
populate the listbox.
Eliyahu
"Devin Wood" <nordlitch@.msn.com> wrote in message
news:Opwr1avLFHA.2648@.TK2MSFTNGP14.phx.gbl...
> Hi,
> I have a page with a ListBox on it, and It's also have a some buttons to
> populate the ListBox by using JavaScript.
> I have no problem with populate the listbox using JavaScript. But when the
> page is submited / postback, the listbox is still empty.
> Do you have any solution for this case (if I still want to use ListBox
> Server Control) ?
> thanks,
> Devin Wood
>

Populate a Listbox by using JavaScript

Hi,

I have a page with a ListBox on it, and It's also have a some buttons to
populate the ListBox by using JavaScript.
I have no problem with populate the listbox using JavaScript. But when the
page is submited / postback, the listbox is still empty.

Do you have any solution for this case (if I still want to use ListBox
Server Control) ?

thanks,
Devin WoodDevin,

You need to pass the new items to the server. It can be done in a hidden
input html control. On server side you will parse the input's value and
populate the listbox.

Eliyahu

"Devin Wood" <nordlitch@.msn.com> wrote in message
news:Opwr1avLFHA.2648@.TK2MSFTNGP14.phx.gbl...
> Hi,
> I have a page with a ListBox on it, and It's also have a some buttons to
> populate the ListBox by using JavaScript.
> I have no problem with populate the listbox using JavaScript. But when the
> page is submited / postback, the listbox is still empty.
> Do you have any solution for this case (if I still want to use ListBox
> Server Control) ?
> thanks,
> Devin Wood

Populate a Password Textbox from DB

Hello,

I have a query that populates several textboxes on my page.

I have a textbox called tboxPassword and it's type is set to password.

The the query runs, the Password box is left empty. I'm assuming this is some feature of the 'password' type assigned to the box. Is there anyway to overcome this? It's ok if the password still appears as ****, but I'd like it to be in the boxes.

Thanks!
Jason<input type="password" value="PASSWORDHERE" /
<asp:textbox TextMode="password" text="blahblahblah" runat="server" /
In either case, the password will appear as ****, but the underlying HTML (viewable through a simple "View Source") will show the password in plain text. In otherwords, you lose any and all password security by doing this and you shouldnot do it.
Actually, you cannot populate a password textbox from code. Even if you try to assign it a value, hoping it will appear as ****, it will not work.

As pickyh3d said, you shouldn't want to do this.

You can't do it anyway.
heh woops. I never tried it, so I just figured it would work... you could cheat and hard code it into an input tag, but you still shouldn't.

Learn something new everyday.

Saturday, March 24, 2012

populate dropdown onchange without reloading page

I have 2 dropdowns, county and district.

When the county changes, I want the district dropdown to automatically
update with a list of districts in that county, but I don't want the
page to have to reload when county changes.

I remember doing this before in classic ASP with javascript, can I do
this with a dropdownlist in ASP.NET or should I stick with the HTML
dropdown?

Thanks,
Peter
--

"I hear ma train a comin'
... hear freedom comin"It has to be done in JavaScript. Whether you use an ASP.Net dropdownlist or
the HTML <select> really doesn't matter. Just note that items added to the
dropdownlist dynamically won't exist when you do post back. You'll need to
use the good-old Request.Form.

You can check out:
http://msdn.microsoft.com/library/d...tSpicedAjax.asp

which has an AJAX implementation of creating linked dropdowns..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Stimp" <ren@.spumco.com> wrote in message
news:slrndkl22h.k78.ren@.carbon.redbrick.dcu.ie...
>I have 2 dropdowns, county and district.
> When the county changes, I want the district dropdown to automatically
> update with a list of districts in that county, but I don't want the
> page to have to reload when county changes.
> I remember doing this before in classic ASP with javascript, can I do
> this with a dropdownlist in ASP.NET or should I stick with the HTML
> dropdown?
> Thanks,
> Peter
> --
> "I hear ma train a comin'
> ... hear freedom comin"

Populate Dropdown with File Names

I'm working with an ASP.Net web page that's using C#. I'm trying to
populate a Dropdown with the File Names that reside in an image folder
that's in the same project. So far all I've been able to find is the
below code...and even then that's not quite what I'm after.

DirectoryInfo di = new DirectoryInfo(@dotnet.itags.org."~/Images/Entry/");
FileInfo[] fis = di.GetFiles();
DropDownList5.DataSource = fis;
DropDownList5.DataTextField = "Name";
DropDownList5.DataValueField = "Name";
DropDownList5.DataBind();

Any help in trying to get this resolved quickly would be appreciated.

ThanksOne thing I neglected to say...the Dropdown will also reside in the
EditItemTemplate of a Formview. Is there a way to bind that control if
it's there?

Thanks Again

Dave wrote:

Quote:

Originally Posted by

I'm working with an ASP.Net web page that's using C#. I'm trying to
populate a Dropdown with the File Names that reside in an image folder
that's in the same project. So far all I've been able to find is the
below code...and even then that's not quite what I'm after.
>
DirectoryInfo di = new DirectoryInfo(@."~/Images/Entry/");
FileInfo[] fis = di.GetFiles();
DropDownList5.DataSource = fis;
DropDownList5.DataTextField = "Name";
DropDownList5.DataValueField = "Name";
DropDownList5.DataBind();
>
Any help in trying to get this resolved quickly would be appreciated.
>
Thanks