473,563 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a popup form that doesn't execute functions- web c#

econVictim
13 New Member
hey guys, i'm new to working with .net c#. I've been doing some more advanced things without knowing much about what i'm doing... I need to create this popup window without using the javascript.. i've been mostly successfull using some simple code however my buttons on the popup don't execute. any ideas and solutions would be greatly appreciated... thank you

this is the front form... form1

[HTML]
<form id="form1" runat="server">
<div>
<asp:LinkButt on Text="userIdlin k" OnCommand="link button1" CommandArgument ="12" runat="server" />
<asp:Label Text="" ID="lblTest" runat="server"> </asp:Label>
</div>
</form>
[/HTML]

this is the codebehind
Expand|Select|Wrap|Line Numbers
  1. namespace popup 
  2. {
  3.     public partial class _Default : System.Web.UI.Page
  4.     {
  5.         protected void Page_Load(object sender, EventArgs e)
  6.         {
  7.  
  8.         }
  9.  
  10.         public void linkbutton1(object sender, EventArgs e)
  11.         {
  12.             string passValue = "";
  13.             passValue = ((LinkButton)sender).CommandArgument;
  14.  
  15.             HtmlGenericControl div = new HtmlGenericControl("div");
  16.             //div.InnerText = "Do you want to request BLAH as your friend?";
  17.             div.Attributes.Add("id","popup");
  18.             div.Attributes.Add("style", "zIndex:3; width:350px; height:150px; border: 2px solid silver; position: absolute; top: 150px; left: 150px; background:#eaeaea; padding: 15px;");
  19.  
  20.             Button btnRequest = new Button();
  21.             btnRequest.ID = "btnRequest";
  22.             btnRequest.Text = "Send my request.";
  23.             btnRequest.Click += new EventHandler(sendRequest);
  24.             btnRequest.Attributes.Add("runat", "server");
  25.  
  26.             Button btnCancel = new Button();
  27.             btnCancel.ID = "btnCancel";
  28.             btnCancel.Text = "Cancel my request.";
  29.             btnCancel.Click += new EventHandler(cancelRequest);
  30.  
  31.             Label lblMessage = new Label();
  32.             lblMessage.ID = "lblMessage";
  33.             lblMessage.Text = "Is " + passValue + " the correct userId?<br>";
  34.  
  35.             div.Controls.Add(lblMessage);
  36.             div.Controls.Add(btnRequest);
  37.             div.Controls.Add(btnCancel);
  38.  
  39.             this.form1.Controls.Add(div);
  40.         }
  41.  
  42.         public void sendRequest(object sender, System.EventArgs e)
  43.         {
  44.             Response.Write("this function does nothing.");
  45.         }
  46.         public void cancelRequest(object sender, System.EventArgs e)
  47.         {
  48.             Response.Write("this function does nothing.");
  49.         }
  50.     }
  51. }
Oct 23 '08 #1
5 2276
nateraaaa
663 Recognized Expert Contributor
So when you click the linkButton you want to open a new .aspx page? On the new .aspx page you need to wire up the onClick event for any buttons on the page. You can do this by viewing the .aspx page in the IDE (in design mode) and double clicking on a button to generate the _Click event of the button.

Nathan
Oct 23 '08 #2
Frinavale
9,735 Recognized Expert Moderator Expert
You shouldn't use Response.Write. This will place the content "Somewhere" on the page...this could be before the <body> or <html> tag and so your page will no longer be valid.

Aside from that, your controls within your "popup" will not work because you are declaring them with a scope of the method that creates them. They have to be declared outside of the method that handles linkbutton1 button click and have to be added to the <div> before the page is loaded.


See this article on how to use dynamic controls in ASP.NET for more information.

What I would recommend is not even dynamically creating your labels and buttons. Simple put a panel on your page that will server as your PopUp (this will be rendered as a <div>) and set it's style to be display:none (or even easier set thePanel.Visibl e = false). When your link button is clicked change the style of the to display:block (or thePanel.Visibl e=true).

-Frinny
Oct 23 '08 #3
econVictim
13 New Member
here is a link to the page where the code example can be seen
www.boilerconne ctions.com/aaronstests/search/popup.aspx

thank you for replying, i'm going to modify the code tonight
Oct 23 '08 #4
econVictim
13 New Member
ok i've fixed the errors... thanks guys.. this is what i've ended up doing

.aspx :

Expand|Select|Wrap|Line Numbers
  1.     <form id="form1" runat="server">
  2.  
  3.         <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CommandArgument="12">LinkButton</asp:LinkButton>&nbsp;
  4.         <asp:Panel ID="Panel1" runat="server" Height="112px" Width="242px"><div style="z-Index:3; width:350px; height:150px; border: 2px solid silver; position: absolute; top: 150px; left: 150px; background:#eaeaea; padding: 15px;">
  5.             <asp:Label Text="" ID="lblTest" runat="server"></asp:Label>
  6.             <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Request" />
  7.             <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Cancel Request" /></div></asp:Panel>
  8.     </form>
  9.  
and the aspx.cs:

Expand|Select|Wrap|Line Numbers
  1. public partial class _Default : System.Web.UI.Page 
  2. {
  3.     protected void Page_Load(object sender, EventArgs e)
  4.     {
  5.         Panel1.Visible = false;
  6.     }
  7.     protected void Button1_Click(object sender, EventArgs e)
  8.     {
  9.         Response.Write("send request");
  10.     }
  11.     protected void Button2_Click(object sender, EventArgs e)
  12.     {
  13.         Response.Write("cancel request");
  14.     }
  15.     protected void LinkButton1_Click(object sender, EventArgs e)
  16.     {
  17.         string passValue = "";
  18.         passValue = ((LinkButton)sender).CommandArgument;
  19.         lblTest.Text = "Is" + passValue + " the correct userId?<br>";
  20.         Panel1.Visible = true;
  21.     }
  22. }
  23.  
after 10 minutes working with visual studio and the help you've mentioned, i've been able to realize many of my misunderstandin gs about writing code. i've been writing all of my code from scratch in dreamweaver.

the working code example is on
http://www.boilerconne ctions.com/aaronstests/search/popup2.aspx
Oct 23 '08 #5
Frinavale
9,735 Recognized Expert Moderator Expert
o
...I've been writing all of my code from scratch in dreamweaver.
Oh yuck.

I'm glad we were able to help you to get it to work :)

-Frinny
Oct 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

38
5024
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find out what i'm doing wrong, and so far it seems i'm doing it the right way. Here's my code...any suggestions would be appreciated. <script...
2
1892
by: Mark | last post by:
The situtation is that I'm trying to ensure that certain functions are only called by functions that I want them to be called from. I have a popup window which has a function which calls a function in the opener window (this works fine). The only thing is when I go to get the caller property of the function in the opener window it is null, it...
4
9289
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form action="MaintNotification.php?ReqID=5" method="post" name="frm5"> <tr align="left" bgcolor="#dddddd" class="text" onClick="submit()"
26
6794
by: Raffi | last post by:
Hi, We have a database application that runs in a popup Internet Explorer application window. The reason for this is to isolate the casual user from the address bar and the typical IE navigation buttons. The application has a browser test page that displays an error message when a popup blocker is found and opens a popup page stating the...
4
22179
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a description and a class_id (stored in the value attribute of each option). The user will then select a class from the drop-down list. What I want...
13
6251
by: ldan | last post by:
Hi everybody, I would not consider myself an expert in javascript - but so far whatever I know, helped me reaching my goals. Recently I started to experience a lot of javascript errors related to opening up a popup window in an application I wrote. The error messages are quite diverse: "Object doesn't support this property or method" or...
3
3959
by: Uwe Range | last post by:
Hi to all, I am displaying a list of records in a subform which is embedded in a popup main form (in order to ensure that users close the form when leaving it). It seems to be impossible to delete a record in this subform. When I switched modal off and tried to delete a record from the list, I deleted a record on another form (below the...
5
8027
by: midnight_use_only | last post by:
hi all, quick question, how do you submit a form to a parent window from a child popup window? i have the following and all online documentation *suggests* that it should work but it does NOT: // Parent window: <script language="JavaScript"> function popup(url, name) { window.open(url, name, "width=800,height=600,scrollbars=yes");
4
8817
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form which allows me to edit the record in the subform. What I want to happen is for subform with the new edits to be updated on the main form when I...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.