473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

button click event problem

I have an ASP.NET application written in C#. one of the web form where you
create user information and user name has a button to click to print
selected user information for the users record. However when this button is
clicked it does nothing the first time, bring up the popup the second time
it is clicked. We need this button to bring up the popup with the
information the first time it is clicked. Any ideas will be greatly
appreciated. The code in the btn_click event is listed below.
private void btnPrint_Click(object sender, System.EventArgs e)

{

string securityQuestion=ddlQuestion.SelectedItem.Text;

securityQuestion=securityQuestion.Replace("'","\\' ");

lblName.Text=txtUserName.Text;

lblPswd.Text=txtPassword.Text;

lblSecQuestion.Text= securityQuestion;

lblAns.Text=txtAnswer.Text;

btnPrint.Attributes.Add("OnClick","return
PrintDocument('"+divusername.ClientID+"');");

}

Thanks!


Jun 2 '06 #1
1 1299
Not sure what you mean by "bring up the popup" but it looks like you're
handling a Click event by adding a client-side click event handler. That
would cause the client-side click event handler to fire only after the
button was clicked a second time.

Instead, if the function being called should be run immediately, just add a
JavaScript to the page that calls the function.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Development Numbskull

Nyuck nyuck nyuck
"ODAN" <ol****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I have an ASP.NET application written in C#. one of the web form where you
create user information and user name has a button to click to print
selected user information for the users record. However when this button is
clicked it does nothing the first time, bring up the popup the second time
it is clicked. We need this button to bring up the popup with the
information the first time it is clicked. Any ideas will be greatly
appreciated. The code in the btn_click event is listed below.
private void btnPrint_Click(object sender, System.EventArgs e)

{

string securityQuestion=ddlQuestion.SelectedItem.Text;

securityQuestion=securityQuestion.Replace("'","\\' ");

lblName.Text=txtUserName.Text;

lblPswd.Text=txtPassword.Text;

lblSecQuestion.Text= securityQuestion;

lblAns.Text=txtAnswer.Text;

btnPrint.Attributes.Add("OnClick","return
PrintDocument('"+divusername.ClientID+"');");

}

Thanks!

Jun 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like...
3
by: Jason Kyle Baginski | last post by:
Here's a little test app to demonstrate a problem I'm having. It creates four buttons, each one with the different FlatStyle types available. Three of them behave exactly the same way(and the...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
4
by: John Smith Jr. | last post by:
I have a very strange problem, I am dynamically creating buttons and events, when page loads the first click works fine, every click there after the event only fires every other click. I made a...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
1
by: Klaus Jensen | last post by:
Hi! This has been annoying me all day, and I can't get it to work It is really driving me nuts! Basicly this simple webapp created to illustrate my problem, renders five buttons, and adds a...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
6
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
7
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, I create button in the code ( Dim Button as new Button), not using button web component (means not drap button and drop it ont he webform), after that I try to use button_click event,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.