Showing posts with label button. Show all posts
Showing posts with label button. 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 Window..ASP.NET

Hi,
I have a webform with a button.
When the user moves their mouse over the button.. I would
like to initiate a mouseover event that shows a small
window with text.. The text will be populated from a
dataset...
Does anyone here know how to do this?
I have code that does the mouseover in javascript.. A
window even pops up.. but I am not sure how to send
dynamic text to this window...
I hope I am being clear enough..
A tooltip would be ok if I could get the data to show up
in 2 lines neatly.. ie
DATAROW 1
DATAROW 2
Any ideas?
ThanksThere are a couple of possibilities.
1. Dynamically create the Window.Open() URL to include enough information to
pull from a database.
2. Feed the data into JavaScript when the page is initially called and
create a tooltip. If you cannot easily do it with HTML, consider setting up
a
layer and painting it on the mouseover event.
NOTE: The second option is more difficult to implement, as different
browsers render layers differently (some older browsers will not render at
all), so the option is more applicable to a controlled environment, like an
Intranet.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"seep" wrote:

> Hi,
> I have a webform with a button.
> When the user moves their mouse over the button.. I would
> like to initiate a mouseover event that shows a small
> window with text.. The text will be populated from a
> dataset...
> Does anyone here know how to do this?
> I have code that does the mouseover in javascript.. A
> window even pops up.. but I am not sure how to send
> dynamic text to this window...
> I hope I am being clear enough..
> A tooltip would be ok if I could get the data to show up
> in 2 lines neatly.. ie
> DATAROW 1
> DATAROW 2
> Any ideas?
> Thanks
>
Check out this article,
http://www.microsoft.com/india/msdn...endarinASP.aspx
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"seep" <seep@.hotmail.com> wrote in message
news:140501c4e775$ae32c810$a301280a@.phx.gbl...
> Hi,
> I have a webform with a button.
> When the user moves their mouse over the button.. I would
> like to initiate a mouseover event that shows a small
> window with text.. The text will be populated from a
> dataset...
> Does anyone here know how to do this?
> I have code that does the mouseover in javascript.. A
> window even pops up.. but I am not sure how to send
> dynamic text to this window...
> I hope I am being clear enough..
> A tooltip would be ok if I could get the data to show up
> in 2 lines neatly.. ie
> DATAROW 1
> DATAROW 2
> Any ideas?
> Thanks
>

Pop Up Window..ASP.NET

Hi,
I have a webform with a button.
When the user moves their mouse over the button.. I would
like to initiate a mouseover event that shows a small
window with text.. The text will be populated from a
dataset...

Does anyone here know how to do this?
I have code that does the mouseover in javascript.. A
window even pops up.. but I am not sure how to send
dynamic text to this window...

I hope I am being clear enough..
A tooltip would be ok if I could get the data to show up
in 2 lines neatly.. ie

DATAROW 1
DATAROW 2

Any ideas?

ThanksThere are a couple of possibilities.

1. Dynamically create the Window.Open() URL to include enough information to
pull from a database.

2. Feed the data into JavaScript when the page is initially called and
create a tooltip. If you cannot easily do it with HTML, consider setting up a
layer and painting it on the mouseover event.

NOTE: The second option is more difficult to implement, as different
browsers render layers differently (some older browsers will not render at
all), so the option is more applicable to a controlled environment, like an
Intranet.

--

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"seep" wrote:

> Hi,
> I have a webform with a button.
> When the user moves their mouse over the button.. I would
> like to initiate a mouseover event that shows a small
> window with text.. The text will be populated from a
> dataset...
> Does anyone here know how to do this?
> I have code that does the mouseover in javascript.. A
> window even pops up.. but I am not sure how to send
> dynamic text to this window...
> I hope I am being clear enough..
> A tooltip would be ok if I could get the data to show up
> in 2 lines neatly.. ie
> DATAROW 1
> DATAROW 2
> Any ideas?
> Thanks
>
Check out this article,
http://www.microsoft.com/india/msdn...endarinASP.aspx

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"seep" <seep@.hotmail.com> wrote in message
news:140501c4e775$ae32c810$a301280a@.phx.gbl...
> Hi,
> I have a webform with a button.
> When the user moves their mouse over the button.. I would
> like to initiate a mouseover event that shows a small
> window with text.. The text will be populated from a
> dataset...
> Does anyone here know how to do this?
> I have code that does the mouseover in javascript.. A
> window even pops up.. but I am not sure how to send
> dynamic text to this window...
> I hope I am being clear enough..
> A tooltip would be ok if I could get the data to show up
> in 2 lines neatly.. ie
> DATAROW 1
> DATAROW 2
> Any ideas?
> Thanks

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.

Wednesday, March 21, 2012

populating a Drop down list

hello,

I need to populate a drop down list when the user clicks
on the arrow button.

how do i do this.

Should i use a html select control or is it possible
using the asp:dropdownlistBoth are ok.

for saving program code, you can choose DropDownList,

if your data come from db, two lines will give your the result
ddl.DataSource = yourProcedure;
ddl.DataBind();

> hello,
> I need to populate a drop down list when the user clicks
> on the arrow button.
> how do i do this.
> Should i use a html select control or is it possible
> using the asp:dropdownlist

What i mean is that the list should only be populated
when the user clicks on it.

Until then it should be empty

>--Original Message--
>Both are ok.
>for saving program code, you can choose DropDownList,
> if your data come from db, two lines will give your the
result
> ddl.DataSource = yourProcedure;
> ddl.DataBind();
>> hello,
>>
>> I need to populate a drop down list when the user
clicks
>> on the arrow button.
>>
>> how do i do this.
>>
>> Should i use a html select control or is it possible
>> using the asp:dropdownlist
>>
>>
>
>.
Can you supply your reasoning for this requirement? This is not the
normal usage of this type of control. You can certainly populate the
list based on selections from other controls, but it might be
difficult to do using the onclick event of the listbox itself.

On Mon, 5 Jul 2004 07:28:15 -0700, "Casey"
<anonymous@.discussions.microsoft.com> wrote:

>
>What i mean is that the list should only be populated
>when the user clicks on it.
>Until then it should be empty
>
>
>>--Original Message--
>>Both are ok.
>>
>>for saving program code, you can choose DropDownList,
>>
>> if your data come from db, two lines will give your the
>result
>> ddl.DataSource = yourProcedure;
>> ddl.DataBind();
>>
>>> hello,
>>>
>>> I need to populate a drop down list when the user
>clicks
>>> on the arrow button.
>>>
>>> how do i do this.
>>>
>>> Should i use a html select control or is it possible
>>> using the asp:dropdownlist
>>>
>>>
>>
>>
>>.
>
Dan,

I am connecting to server at a distant location to
retrieve the data for the listbox, and the data has to be
loaded up only when the user wants to look at the
information,

I know there are other ways of doing this but this is
requested by the user

can you give me any ideas on this..

>--Original Message--
>Can you supply your reasoning for this requirement? This
is not the
>normal usage of this type of control. You can certainly
populate the
>list based on selections from other controls, but it
might be
>difficult to do using the onclick event of the listbox
itself.
>
>On Mon, 5 Jul 2004 07:28:15 -0700, "Casey"
><anonymous@.discussions.microsoft.com> wrote:
>>
>>
>>What i mean is that the list should only be populated
>>when the user clicks on it.
>>
>>Until then it should be empty
>>
>>
>>
>>
>>>--Original Message--
>>>Both are ok.
>>>
>>>for saving program code, you can choose DropDownList,
>>>
>>> if your data come from db, two lines will give your
the
>>result
>>> ddl.DataSource = yourProcedure;
>>> ddl.DataBind();
>>>
>>>> hello,
>>>>
>>>> I need to populate a drop down list when the user
>>clicks
>>>> on the arrow button.
>>>>
>>>> how do i do this.
>>>>
>>>> Should i use a html select control or is it possible
>>>> using the asp:dropdownlist
>>>>
>>>>
>>>
>>>
>>>.
>>>
>.
There is a user event that occurs when you click on the dropdown list
I think (not 100% sure). You may be able to link to that. However...

If you are going to go to the server to get the data, this will be a
significant pause to build the list. Also, when you come back, you
would have to manually "open" that list as if you just clicked on it.
Not exactly a smooth transition.

I suggest that you should be able to determine when the list would
need to be built and do this when necessary. Worst case, provide a
button that says "Load List" that the user can click and then populate
the dropdown list.

On Mon, 5 Jul 2004 14:19:26 -0700, "Casey"
<anonymous@.discussions.microsoft.com> wrote:

>Dan,
> I am connecting to server at a distant location to
>retrieve the data for the listbox, and the data has to be
>loaded up only when the user wants to look at the
>information,
>I know there are other ways of doing this but this is
>requested by the user
>can you give me any ideas on this..
>
>>--Original Message--
>>Can you supply your reasoning for this requirement? This
>is not the
>>normal usage of this type of control. You can certainly
>populate the
>>list based on selections from other controls, but it
>might be
>>difficult to do using the onclick event of the listbox
>itself.
>>
>>
>>On Mon, 5 Jul 2004 07:28:15 -0700, "Casey"
>><anonymous@.discussions.microsoft.com> wrote:
>>
>>>
>>>
>>>What i mean is that the list should only be populated
>>>when the user clicks on it.
>>>
>>>Until then it should be empty
>>>
>>>
>>>
>>>
>>>>--Original Message--
>>>>Both are ok.
>>>>
>>>>for saving program code, you can choose DropDownList,
>>>>
>>>> if your data come from db, two lines will give your
>the
>>>result
>>>> ddl.DataSource = yourProcedure;
>>>> ddl.DataBind();
>>>>
>>>>> hello,
>>>>>
>>>>> I need to populate a drop down list when the user
>>>clicks
>>>>> on the arrow button.
>>>>>
>>>>> how do i do this.
>>>>>
>>>>> Should i use a html select control or is it possible
>>>>> using the asp:dropdownlist
>>>>>
>>>>>
>>>>
>>>>
>>>>.
>>>>
>>
>>.
>
thanks for your help dan..

I will take your advice,

regards

casey

>--Original Message--
>There is a user event that occurs when you click on the
dropdown list
>I think (not 100% sure). You may be able to link to
that. However...
>If you are going to go to the server to get the data,
this will be a
>significant pause to build the list. Also, when you come
back, you
>would have to manually "open" that list as if you just
clicked on it.
>Not exactly a smooth transition.
>I suggest that you should be able to determine when the
list would
>need to be built and do this when necessary. Worst case,
provide a
>button that says "Load List" that the user can click and
then populate
>the dropdown list.
>
>On Mon, 5 Jul 2004 14:19:26 -0700, "Casey"
><anonymous@.discussions.microsoft.com> wrote:
>>Dan,
>>
>> I am connecting to server at a distant location to
>>retrieve the data for the listbox, and the data has to
be
>>loaded up only when the user wants to look at the
>>information,
>>
>>I know there are other ways of doing this but this is
>>requested by the user
>>
>>can you give me any ideas on this..
>>
>>
>>
>>>--Original Message--
>>>Can you supply your reasoning for this requirement?
This
>>is not the
>>>normal usage of this type of control. You can
certainly
>>populate the
>>>list based on selections from other controls, but it
>>might be
>>>difficult to do using the onclick event of the listbox
>>itself.
>>>
>>>
>>>On Mon, 5 Jul 2004 07:28:15 -0700, "Casey"
>>><anonymous@.discussions.microsoft.com> wrote:
>>>
>>>>
>>>>
>>>>What i mean is that the list should only be populated
>>>>when the user clicks on it.
>>>>
>>>>Until then it should be empty
>>>>
>>>>
>>>>
>>>>
>>>>>--Original Message--
>>>>>Both are ok.
>>>>>
>>>>>for saving program code, you can choose DropDownList,
>>>>>
>>>>> if your data come from db, two lines will give your
>>the
>>>>result
>>>>> ddl.DataSource = yourProcedure;
>>>>> ddl.DataBind();
>>>>>
>>>>>> hello,
>>>>>>
>>>>>> I need to populate a drop down list when the user
>>>>clicks
>>>>>> on the arrow button.
>>>>>>
>>>>>> how do i do this.
>>>>>>
>>>>>> Should i use a html select control or is it
possible
>>>>>> using the asp:dropdownlist
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>.
>>>>>
>>>
>>>.
>>>
>.

populating a Drop down list

hello,
I need to populate a drop down list when the user clicks
on the arrow button.
how do i do this.
Should i use a html select control or is it possible
using the asp:dropdownlistBoth are ok.
for saving program code, you can choose DropDownList,
if your data come from db, two lines will give your the result
ddl.DataSource = yourProcedure;
ddl.DataBind();

> hello,
> I need to populate a drop down list when the user clicks
> on the arrow button.
> how do i do this.
> Should i use a html select control or is it possible
> using the asp:dropdownlist
>

What i mean is that the list should only be populated
when the user clicks on it.
Until then it should be empty

>--Original Message--
>Both are ok.
>for saving program code, you can choose DropDownList,
> if your data come from db, two lines will give your the
result
> ddl.DataSource = yourProcedure;
> ddl.DataBind();
>
clicks
>
>.
>
Can you supply your reasoning for this requirement? This is not the
normal usage of this type of control. You can certainly populate the
list based on selections from other controls, but it might be
difficult to do using the onclick event of the listbox itself.
On Mon, 5 Jul 2004 07:28:15 -0700, "Casey"
<anonymous@.discussions.microsoft.com> wrote:
>
>What i mean is that the list should only be populated
>when the user clicks on it.
>Until then it should be empty
>
>
>result
>clicks
Dan,
I am connecting to server at a distant location to
retrieve the data for the listbox, and the data has to be
loaded up only when the user wants to look at the
information,
I know there are other ways of doing this but this is
requested by the user
can you give me any ideas on this..

>--Original Message--
>Can you supply your reasoning for this requirement? This
is not the
>normal usage of this type of control. You can certainly
populate the
>list based on selections from other controls, but it
might be
>difficult to do using the onclick event of the listbox
itself.
>
>On Mon, 5 Jul 2004 07:28:15 -0700, "Casey"
><anonymous@.discussions.microsoft.com> wrote:
>
the
>.
>
There is a user event that occurs when you click on the dropdown list
I think (not 100% sure). You may be able to link to that. However...
If you are going to go to the server to get the data, this will be a
significant pause to build the list. Also, when you come back, you
would have to manually "open" that list as if you just clicked on it.
Not exactly a smooth transition.
I suggest that you should be able to determine when the list would
need to be built and do this when necessary. Worst case, provide a
button that says "Load List" that the user can click and then populate
the dropdown list.
On Mon, 5 Jul 2004 14:19:26 -0700, "Casey"
<anonymous@.discussions.microsoft.com> wrote:
>Dan,
> I am connecting to server at a distant location to
>retrieve the data for the listbox, and the data has to be
>loaded up only when the user wants to look at the
>information,
>I know there are other ways of doing this but this is
>requested by the user
>can you give me any ideas on this..
>
>
>is not the
>populate the
>might be
>itself.
>the
thanks for your help dan..
I will take your advice,
regards
casey

>--Original Message--
>There is a user event that occurs when you click on the
dropdown list
>I think (not 100% sure). You may be able to link to
that. However...
>If you are going to go to the server to get the data,
this will be a
>significant pause to build the list. Also, when you come
back, you
>would have to manually "open" that list as if you just
clicked on it.
>Not exactly a smooth transition.
>I suggest that you should be able to determine when the
list would
>need to be built and do this when necessary. Worst case,
provide a
>button that says "Load List" that the user can click and
then populate
>the dropdown list.
>
>On Mon, 5 Jul 2004 14:19:26 -0700, "Casey"
><anonymous@.discussions.microsoft.com> wrote:
>
be
This
certainly
possible
>.
>

Friday, March 16, 2012

populating ddl and setting selectedvalue

When a button is clicked, I want to populate multiple ddl's and under
certain circumstances I want to set the SelectedValue. I've tried different
variations of this:
protected void btnImport_Click(object sender, EventArgs e)
{
[snip]
int tblcols = dsCsv.Tables["csv"].Columns.Count;
for(int i=0; i<tblcols; i++)
{
ListItem liItem = new ListItem();
liItem.Text = dsCsv.Tables["csv"].Columns[i].ToString();
liItem.Value = dsCsv.Tables["csv"].Columns[i].ToString();
ddlAddress.Items.Add(liItem);
ddlOrganization.Items.Add(liItem);
if (liItem.Text.ToLower().IndexOf("company") >=0)
{
ddlOrganization.Items.FindByText(liItem.Text).Selected = true;
}
}
}
This doesn't work. Although items were added, the code won't recognize
these items until the entire btnImport_Click is finished. How can I
accomplish this?
Thanks.Sharing ListItems is a bad idea. The problem is that Selected is a property
of an ListItem rather than the ddl the item belongs to. It means that as
soon as you select an item in one list, it will become selected also in
another list.
Create separate instances if ListItems for every list.
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"J" <nobody@.nowhere.com> wrote in message
news:13ufgs5682locff@.corp.supernews.com...
> When a button is clicked, I want to populate multiple ddl's and under
> certain circumstances I want to set the SelectedValue. I've tried
> different variations of this:
> protected void btnImport_Click(object sender, EventArgs e)
> {
> [snip]
> int tblcols = dsCsv.Tables["csv"].Columns.Count;
> for(int i=0; i<tblcols; i++)
> {
> ListItem liItem = new ListItem();
> liItem.Text = dsCsv.Tables["csv"].Columns[i].ToString();
> liItem.Value = dsCsv.Tables["csv"].Columns[i].ToString();
> ddlAddress.Items.Add(liItem);
> ddlOrganization.Items.Add(liItem);
> if (liItem.Text.ToLower().IndexOf("company") >=0)
> {
> ddlOrganization.Items.FindByText(liItem.Text).Selected = true;
> }
> }
> }
> This doesn't work. Although items were added, the code won't recognize
> these items until the entire btnImport_Click is finished. How can I
> accomplish this?
> Thanks.
>
Ah, this bit of info solves my issues. Thanks.
"Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@.mMvVpPsS.org> wrote in
message news:%23GemqocjIHA.4376@.TK2MSFTNGP05.phx.gbl...
> Sharing ListItems is a bad idea. The problem is that Selected is a
> property of an ListItem rather than the ddl the item belongs to. It means
> that as soon as you select an item in one list, it will become selected
> also in another list.
> Create separate instances if ListItems for every list.
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
> "J" <nobody@.nowhere.com> wrote in message
> news:13ufgs5682locff@.corp.supernews.com...
>