Showing posts with label box. Show all posts
Showing posts with label box. Show all posts

Saturday, March 24, 2012

Passing variables between pages

Hello, I have a page where I ask the user to enter text into a text box, and clicking a button which sends them to another page. I am using the code (in C#):

void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("results.aspx?q=" + TextBox1.Text);
}

which works fine, but how would I call upon the variable in the results page? Also, how could I check the TextBox1.Text to see if it is blank? I tried:

If (TextBox1.Text = "")

but it tells me that I can't change from a string to a bool. Any help would be great, thanks.Well, in VB to check for empty strings I do this.

If TextBox1.Text Is String.Empty Then
' Yell at the person for not entering any text
Else
' Thank them for entering something
End If

Wednesday, March 21, 2012

passing variables....

i am trying to pass a variable called EventID (which is read from my SQLDataBase) from my aspx page box to a textbox in the showmodaldialog.

I have a main aspx page called Main_calendar, where when you click a hyperlink a showmodaldialog box appears giving you two options: edit or delete. on the showmodaldialog box there is also a textbox (not visible at runtime) where i would like the EventID to be written to. when you click either of the two link buttons, a new aspx page is opened, which will take the eventID written in that textbox and perform a query based on it in the new edit/delete page.

im extremely stuck as to how i can retrieve this value and input it into the texbox first and then take the value of the textbox and write it to another webform. my programming isnt so great so please bear with me!

i can see how to to do the edit/delete query if i can just get the value written in the textbox into the webform - then the rest should just be easy (touch wood). but i just dont know where to start on the first bit! ive been stuck on this for days,

id greatly appreciate anyones help on this, thanks!

code attached as below:

Main_calendar code page:

int

evID = (int)dr["EventID"];

HyperLink link =new HyperLink();
link.ForeColor = Color.FromName(evColor);
link.ID = " + evID + ";
link.NavigateUrl = "#";
link.Attributes.Add("onClick", "window.showModalDialog('UpdateDeleteDialog.aspx', null, 'dialogHeight: 130px; dialogWidth: 235px; edge: Raised; center: Yes; help: No; resizable: No; status: No; ')");

evID is the Id of the event that i wish to write to a textbox on the UpdateDeleteDialog page

updatedeletedailog page

using

System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CalendarBCP
{
///<summary>
/// Summary description for UpdateDeleteDialog.
///</summary>publicclass UpdateDeleteDialog : System.Web.UI.Page
{
protected System.Web.UI.WebControls.LinkButton LnkBtn_EditEvent;
protected System.Web.UI.WebControls.LinkButton LnkBtn_DeleteEvent;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.LinkButton Btn_Cancel;
protected System.Web.UI.WebControls.TextBoxTxt_EventID;
protected System.Web.UI.WebControls.Panel Panel1;

privatevoid Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

private

void Btn_Cancel_Click(object sender, System.EventArgs e)
{
Btn_Cancel.Attributes.Add("onclick", "window.close(); return:false;");
}privatevoid LnkBtn_EditEvent_Click(object sender, System.EventArgs e)
{
LnkBtn_EditEvent.Attributes.Add("onclick", "window.open(UpdateEvent.aspx);");
}privatevoid LnkBtn_DeleteEvent_Click(object sender, System.EventArgs e)
{
Response.Redirect("DeleteEvent.aspx");
}

Txt_EventID id the textbox in the UpdateDeleteDialog page where the eventId should be written

updatedeletdialog html:

<%@dotnet.itags.org. Page language="c#" Codebehind="UpdateDeleteDialog.aspx.cs" AutoEventWireup="false" Inherits="CalendarBCP.UpdateDeleteDialog" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>UpdateDeleteDialog</title>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="C#" name="CODE_LANGUAGE">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

</HEAD>

<body ms_positioning="GridLayout">

<form id="Form1" method="post" runat="server">

<asp:Panel id="Panel1" style="Z-INDEX: 105; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"

Width="216px" Height="64px" BackColor="Gainsboro">

<P>

<asp:Label id="Label1" runat="server" BackColor="DarkGreen" Height="24px" Width="200px" ForeColor="White"

Font-Size="10pt" Font-Names="Tahoma">Please Select one of the following:</asp:Label>

<asp:TextBox id="Txt_EventID" runat="server" Width="72px" Visible="False"></asp:TextBox><BR>

<asp:LinkButton id="LnkBtn_EditEvent" runat="server" BackColor="Transparent" ForeColor="DarkGreen"

Font-Size="10pt" Font-Names="Tahoma">Edit Event</asp:LinkButton>

<asp:LinkButton id="LnkBtn_DeleteEvent" runat="server" ForeColor="DarkGreen" Font-Size="10pt" Font-Names="Tahoma">Delete Event</asp:LinkButton>

<asp:LinkButton id="Btn_Cancel" runat="server" ForeColor="DarkGreen" Font-Size="10pt" Font-Names="Tahoma">Cancel</asp:LinkButton></P>

</asp:Panel></form>

</body>

</HTML>

Thanks in advance!

1. Not related to your question, but move ALL of your Attributes.Add statements into the Page_Load event handler.
2. Check here for the ways to pass varibles using showModalDialog:
http://forums.asp.net/thread/1240957.aspx

NC...


Thanks! just what i need!Big Smile [:D]

Passing variables, please please help :)

I wrote a much more complicated version of this question earlier and no one answered so i thought i'd simplify it. I want to have a text box and a submit button on page1.aspx. I want a user to type something into the textbox and when they click on the submit button to get passed to page2.aspx?keyword=[value of textbox]. I have tried about five million different ways, html forms don't seem to work because i'm using a master page and i can't get anything else to do it. Please please please could someone help me before i lose all sense of reality :)

Thanks,

Dave

Protected Sub button_click(...) Response.Redirect("page2.aspx?text=" & textbox1.text)End Sub

I cannot begin to express my thanks for that, it is unbelivable, but i have been trying to get it to do that for hours and have been on about 8 forums chatting with people all over the place and tried pages of code. It seemed strange it wasn't possible to do it very simply with hardly any code and you have just shown me how. You may actually be solely responsible for preventing me from losing my sanity and for that i am truely grateful. If i can ever do anything in return then please don't hesitate to ask, although given i couldn't even work that out i wouldn't be too sure you'll get anything useful in response! :)

Once again thank you so, so much, you are an absolute and complete life saver.

Dave

Friday, March 16, 2012

Password control

Is there a webforms equivalent to the HTML password box control?
I don't see one in the toolbox.

RegardsJust use the Textbox control and set its TextMode property to password:

<asp:TextBox id="TextBox1" runat="server"
TextMode="Password"></asp:TextBox
"Jerry" <JerryOfBorg@.Yahoo.com> wrote in message
news:%23gzS8pQ8DHA.1596@.TK2MSFTNGP10.phx.gbl...
> Is there a webforms equivalent to the HTML password box control?
> I don't see one in the toolbox.
> Regards
Thanks Ken.

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:OFmMCyQ8DHA.1052@.TK2MSFTNGP12.phx.gbl...
> Just use the Textbox control and set its TextMode property to password:
> <asp:TextBox id="TextBox1" runat="server"
> TextMode="Password"></asp:TextBox>
>
> "Jerry" <JerryOfBorg@.Yahoo.com> wrote in message
> news:%23gzS8pQ8DHA.1596@.TK2MSFTNGP10.phx.gbl...
> > Is there a webforms equivalent to the HTML password box control?
> > I don't see one in the toolbox.
> > Regards

Password field

In ASP.Net I would like to create a text box that is a Password Field.
How do I do that ?
When I use the Textbox Field (from Toolbox - Standard), I did not find
anything there that can make it a password field.
When I use the Input (Password) Field (From Toolbox - HTML), in my
Submit command button when I do Request.Form("txtPassword") or
Request.QueryString("txtPassword") it returns nothing.

This is from Page1.aspx
<input id="txtPassword" type="password" />

This is from Page1.aspx.vb:
Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click
sPassword = Request.Form("txtPassword") --nothing

Thank you.<fiefie.niles@.gmail.comwrote in message
news:1177277182.866667.28220@.b75g2000hsg.googlegro ups.com...

Quote:

Originally Posted by

In ASP.Net I would like to create a text box that is a Password Field.
How do I do that ?


<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />
When I click on the hyperlink you wrote
news:1177277182.866667.28220@.b75g2000hsg.googlegro ups.com...
it says "Page not found".
Can you please retype the link ? Thank you very much.

On Apr 22, 4:43 pm, "Mark Rae" <m...@.markNOSPAMrae.netwrote:

Quote:

Originally Posted by

<fiefie.ni...@.gmail.comwrote in message
>
news:1177277182.866667.28220@.b75g2000hsg.googlegro ups.com...
>

Quote:

Originally Posted by

In ASP.Net I would like to create a text box that is a Password Field.
How do I do that ?


>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />


You can only click on that hyperlink from a newsreader, not from a browser.

Notice the news: protocol

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<fiefie.niles@.gmail.comwrote in message
news:1177278845.344621.129990@.y80g2000hsf.googlegr oups.com...

Quote:

Originally Posted by

When I click on the hyperlink you wrote
news:1177277182.866667.28220@.b75g2000hsg.googlegro ups.com...
it says "Page not found".
Can you please retype the link ? Thank you very much.
>
On Apr 22, 4:43 pm, "Mark Rae" <m...@.markNOSPAMrae.netwrote:

Quote:

Originally Posted by

><fiefie.ni...@.gmail.comwrote in message
>>
>news:1177277182.866667.28220@.b75g2000hsg.googlegro ups.com...
>>

Quote:

Originally Posted by

In ASP.Net I would like to create a text box that is a Password Field.
How do I do that ?


>>
><asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />


>
>


<fiefie.niles@.gmail.comwrote in message
news:1177278845.344621.129990@.y80g2000hsf.googlegr oups.com...

Quote:

Originally Posted by

When I click on the hyperlink you wrote


What hyperlink...?
See my earlier reply, MArk.

He means the news: protocol hyperlink which is quoted
in your reply because you used a newsreader to reply to him.

He's using a browser...and the news: protocol doesn't work in browsers
unless it also has the double slashes and the server's address.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Mark Rae" <mark@.markNOSPAMrae.netwrote in message news:O5dS0pShHHA.1312@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

<fiefie.niles@.gmail.comwrote in message
news:1177278845.344621.129990@.y80g2000hsf.googlegr oups.com...
>

Quote:

Originally Posted by

>When I click on the hyperlink you wrote


>
What hyperlink...?
>


"Juan T. Llibre" <nomailreplies@.nowhere.comwrote in message
news:ezMak%23ShHHA.3960@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

See my earlier reply, MArk.
>
He means the news: protocol hyperlink which is quoted
in your reply because you used a newsreader to reply to him.
>
He's using a browser...and the news: protocol doesn't work in browsers
unless it also has the double slashes and the server's address.


Ah right...
Oh, I see your reply. I got it. Sorry about the confusion.
That works !
Thanks a lot.

On Apr 22, 5:51 pm, "Mark Rae" <m...@.markNOSPAMrae.netwrote:

Quote:

Originally Posted by

"Juan T. Llibre" <nomailrepl...@.nowhere.comwrote in messagenews:ezMak%23ShHHA.3960@.TK2MSFTNGP02.phx.gb l...
>

Quote:

Originally Posted by

See my earlier reply, MArk.


>

Quote:

Originally Posted by

He means the news: protocol hyperlink which is quoted
in your reply because you used a newsreader to reply to him.


>

Quote:

Originally Posted by

He's using a browser...and the news: protocol doesn't work in browsers
unless it also has the double slashes and the server's address.


>
Ah right...

Password field

In ASP.Net I would like to create a text box that is a Password Field.
How do I do that ?
When I use the Textbox Field (from Toolbox - Standard), I did not find
anything there that can make it a password field.
When I use the Input (Password) Field (From Toolbox - HTML), in my
Submit command button when I do Request.Form("txtPassword") or
Request.QueryString("txtPassword") it returns nothing.
This is from Page1.aspx
<input id="txtPassword" type="password" />
This is from Page1.aspx.vb:
Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdSubmit.Click
sPassword = Request.Form("txtPassword") --> nothing
Thank you.<fiefie.niles@.gmail.com> wrote in message
news:1177277182.866667.28220@.b75g2000hsg.googlegroups.com...

> In ASP.Net I would like to create a text box that is a Password Field.
> How do I do that ?
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />
When I click on the hyperlink you wrote
news:1177277182.866667.28220@.b75g2000hsg.googlegroups.com...
it says "Page not found".
Can you please retype the link ? Thank you very much.
On Apr 22, 4:43 pm, "Mark Rae" <m...@.markNOSPAMrae.net> wrote:
> <fiefie.ni...@.gmail.com> wrote in message
> news:1177277182.866667.28220@.b75g2000hsg.googlegroups.com...
>
> <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" />
You can only click on that hyperlink from a newsreader, not from a browser.
Notice the news: protocol
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
<fiefie.niles@.gmail.com> wrote in message
news:1177278845.344621.129990@.y80g2000hsf.googlegroups.com...
> When I click on the hyperlink you wrote
> news:1177277182.866667.28220@.b75g2000hsg.googlegroups.com...
> it says "Page not found".
> Can you please retype the link ? Thank you very much.
> On Apr 22, 4:43 pm, "Mark Rae" <m...@.markNOSPAMrae.net> wrote:
>
<fiefie.niles@.gmail.com> wrote in message
news:1177278845.344621.129990@.y80g2000hsf.googlegroups.com...

> When I click on the hyperlink you wrote
What hyperlink...?
See my earlier reply, MArk.
He means the news: protocol hyperlink which is quoted
in your reply because you used a newsreader to reply to him.
He's using a browser...and the news: protocol doesn't work in browsers
unless it also has the double slashes and the server's address.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Mark Rae" <mark@.markNOSPAMrae.net> wrote in message news:O5dS0pShHHA.1312@.TK2MSFTNGP03.phx
.gbl...
> <fiefie.niles@.gmail.com> wrote in message
> news:1177278845.344621.129990@.y80g2000hsf.googlegroups.com...
>
> What hyperlink...?
>
"Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
news:ezMak%23ShHHA.3960@.TK2MSFTNGP02.phx.gbl...

> See my earlier reply, MArk.
> He means the news: protocol hyperlink which is quoted
> in your reply because you used a newsreader to reply to him.
> He's using a browser...and the news: protocol doesn't work in browsers
> unless it also has the double slashes and the server's address.
Ah right...
Oh, I see your reply. I got it. Sorry about the confusion.
That works !
Thanks a lot.
On Apr 22, 5:51 pm, "Mark Rae" <m...@.markNOSPAMrae.net> wrote:
> "Juan T. Llibre" <nomailrepl...@.nowhere.com> wrote in messagenews:ezMak%23
ShHHA.3960@.TK2MSFTNGP02.phx.gbl...
>
>
>
> Ah right...

Password Input Boxes

Hey Guys,

How would I make a password box that shows the ********** ?

Something like this
<asp:PassBox id="NewPassword" runat="server" /
Just can't find the answer.

Thank you!Hi there,

The TextBox web control has a TextMode called "Password" that does this for you.

HTH,

Covo
You would do this.

<asp:textbox id="passwordfield" textmode="password" runat="server" /
Then it will show up as ****

Keep in mind, any time you want a user to type something in, you always use the asp:textbox. But the textbox has different 'texmode's. such as single line, multi line, or password. Does this help?