Showing posts with label text. Show all posts
Showing posts with label text. Show all posts

Thursday, March 29, 2012

Pass one variable from one form to other

Hi,

I want to transfer the value of one variable ( basicaly text of a text filed) from one form to other form ...

i tried Server.Transfer("next_form.aspx") ..and then tried Request.Form("text_field") to retrieve it's content .. but doesnt work ...

i also tried Response.Redirect("next_form.aspx") ..and then tried Request.Form("text_field") to retrieve it's content .. but doesnt work ...

I think i am doing it wrong ... how can i do it .. anyone plz help :(

Thanks
imranIn your first form, put the following in your sub that gets called when you submit the form...

Response.Redirect("form2.aspx?myValue=" & myTextBox.Text)

Then in your second page...

Sub Page_Load()
TextBox2.Text = Request.QueryString("myValue")
End Sub
Hi,

When using Server.Transfer its preserveForm arguement to TRUE. This makes viewstate, event procedure available in destination form.

When using Response.Redirect, you can use querystring to pass information to the destination form like Response.Redirect("test.aspx?id=10");

HTH,
Shamir
Also see below article it could helps you

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

Pass parameter to Popup window

I have 2 webform in vb.NET application.
On Webform1, I have one text box1 and one button.
on Webform2, I have one text box .
I need transfer the value of textbox 1 in webform1 to textbox2 in
webform2. and popup webform2 when user click on the button on webform1.
I have code in webform1:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
End Sub
and following code in webform2:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Request("a").ToString
End Sub
I could not get the result unless I click on the button1 twice. i know
what happen in here but have no solution. I will be appreciated if you
could help here.
Thanks in advanced,
DiHi ,
You can achieve this by injecting a javascript in the Button1 click
event on the server side . Write an function to inject an javascript in the
webform1 button1 click.
Don't do anything with Attributes of button1 as it won't achieve result u
requires as the 1st page the textbox1 value would be blank.
private void openWindowInjectScript(){
string myScript;
myScript = "<scr" + "ipt>window.open('WebForm2.aspx?a=" + txtIdfield.Value
+ "',null,'height=250, width=250,status= no,resizable= no, scrollbars=no,
toolbar=no,location=no,menubar=no'); </scr" + "ipt>";
this.Page.RegisterStartupScript("JavaScript",myScript);
}
In the webform1.aspx button1_Click event
private void Button1_Click(object sender, System.EventArgs e)
{
openWindowInjectScript();
}
Basically openwindowInjectScript register a script at pageload and which
will make to open an window with current values.
This is the way out for it and it should work
Regards
IntelYogi
"dyw55a@.yahoo.com" wrote:

> I have 2 webform in vb.NET application.
> On Webform1, I have one text box1 and one button.
> on Webform2, I have one text box .
> I need transfer the value of textbox 1 in webform1 to textbox2 in
> webform2. and popup webform2 when user click on the button on webform1.
> I have code in webform1:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
> TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
> resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
> End Sub
> and following code in webform2:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> TextBox1.Text = Request("a").ToString
> End Sub
>
> I could not get the result unless I click on the button1 twice. i know
> what happen in here but have no solution. I will be appreciated if you
> could help here.
> Thanks in advanced,
> Di
>
Thank you for your reply. But actually I tried and this did not work
for some reason, any idea?
Try this onClick event of your button
Response.Write("<SCRIPT>");
Response.Write("window.open('page,aspx?value=" + myval +
" ',null,'height=200,width=900,status=yes,
toolbar=no,menubar=no,location=no')
;
");
Response.Write("</SCRIPT>");
I think this will do the trick, tell me if not
dyw55a@.yahoo.com wrote in message news:<1117647067.875660.133640@.g43g2000cwa.googlegroups.c
om>...
> Thank you for your reply. But actually I tried and this did not work
> for some reason, any idea?

Pass parameter to Popup window

I have 2 webform in vb.NET application.
On Webform1, I have one text box1 and one button.
on Webform2, I have one text box .
I need transfer the value of textbox 1 in webform1 to textbox2 in
webform2. and popup webform2 when user click on the button on webform1.

I have code in webform1:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
End Sub

and following code in webform2:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Request("a").ToString
End Sub

I could not get the result unless I click on the button1 twice. i know
what happen in here but have no solution. I will be appreciated if you
could help here.

Thanks in advanced,
DiHi ,
You can achieve this by injecting a javascript in the Button1 click
event on the server side . Write an function to inject an javascript in the
webform1 button1 click.
Don't do anything with Attributes of button1 as it won't achieve result u
requires as the 1st page the textbox1 value would be blank.

private void openWindowInjectScript(){
string myScript;
myScript = "<scr" + "ipt>window.open('WebForm2.aspx?a=" + txtIdfield.Value
+ "',null,'height=250, width=250,status= no,resizable= no, scrollbars=no,
toolbar=no,location=no,menubar=no'); </scr" + "ipt>";
this.Page.RegisterStartupScript("JavaScript",myScript);
}

In the webform1.aspx button1_Click event
private void Button1_Click(object sender, System.EventArgs e)
{
openWindowInjectScript();
}
Basically openwindowInjectScript register a script at pageload and which
will make to open an window with current values.

This is the way out for it and it should work

Regards
IntelYogi

"dyw55a@.yahoo.com" wrote:

> I have 2 webform in vb.NET application.
> On Webform1, I have one text box1 and one button.
> on Webform2, I have one text box .
> I need transfer the value of textbox 1 in webform1 to textbox2 in
> webform2. and popup webform2 when user click on the button on webform1.
> I have code in webform1:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
> TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
> resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
> End Sub
> and following code in webform2:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> TextBox1.Text = Request("a").ToString
> End Sub
>
> I could not get the result unless I click on the button1 twice. i know
> what happen in here but have no solution. I will be appreciated if you
> could help here.
> Thanks in advanced,
> Di
>
Thank you for your reply. But actually I tried and this did not work
for some reason, any idea?
Try this onClick event of your button

Response.Write("<SCRIPT>");
Response.Write("window.open('page,aspx?value=" + myval +
"',null,'height=200,width=900,status=yes,toolbar=no ,menubar=no,location=no');
");
Response.Write("</SCRIPT>");

I think this will do the trick, tell me if not

dyw55a@.yahoo.com wrote in message news:<1117647067.875660.133640@.g43g2000cwa.googlegroups. com>...
> Thank you for your reply. But actually I tried and this did not work
> for some reason, any idea?
i'd tried both suggest solutions from Yogi, but it seems not work for me...is any solution yet?

the prob is...webform2's page_load will be run 1st b4 the button_click event run...so any wisdom can help up?

From http://www.developmentnow.com/g/8_2...opup-window.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Monday, March 26, 2012

pass text to javascript function

Hello,
I found this code and I want to pass this function a value
from a dataset.

How do I do this?

<INPUT onmouseover="func()" type="button" value="Button"
<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script<INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button"
In the code behind (C#):

myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");

Eliyahu

"prav" <prav@.hotmail.com> wrote in message
news:10ca01c4d624$ae4a5410$a501280a@.phx.gbl...
> Hello,
> I found this code and I want to pass this function a value
> from a dataset.
> How do I do this?
> <INPUT onmouseover="func()" type="button" value="Button">
>
> <script type=text/javascript>
> function func()
> {
> //you could put anything here, e.g. opening a window etc.
> alert('Hi');
> }
> </script>
Eliyahu Goldin wrote:
> <INPUT runat="server" id="myButton" onmouseover="func()"
> type="button" value="Button">
> In the code behind (C#):
> myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
> text");
> Eliyahu

You might want to put quotes around that text:

String.Format("func('{0}')", "my text");

(and then you could still have problems with quotes inside the string)

Hans Kesting

pass text to javascript function

Hello,
I found this code and I want to pass this function a value
from a dataset.
How do I do this?
<INPUT onmouseover="func()" type="button" value="Button">
<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script><INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button">
In the code behind (C#):
myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");
Eliyahu
"prav" <prav@.hotmail.com> wrote in message
news:10ca01c4d624$ae4a5410$a501280a@.phx.gbl...
> Hello,
> I found this code and I want to pass this function a value
> from a dataset.
> How do I do this?
> <INPUT onmouseover="func()" type="button" value="Button">
>
> <script type=text/javascript>
> function func()
> {
> //you could put anything here, e.g. opening a window etc.
> alert('Hi');
> }
> </script>
>
Eliyahu Goldin wrote:
> <INPUT runat="server" id="myButton" onmouseover="func()"
> type="button" value="Button">
> In the code behind (C#):
> myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
> text");
> Eliyahu
>
You might want to put quotes around that text:
String.Format("func('{0}')", "my text");
(and then you could still have problems with quotes inside the string)
Hans Kesting

pass the web value from asp.net to asp by url

hi all,

i have two web files, one is *.aspx and the other is *.asp

i need pass textbox.text value from *.aspx to *.asp

so i can process the value(ex:string ) in *.asp

i pass the value like this

<a href="http://links.10026.com/?link=iflowall.asp?case_no=<%=(case.Text)%>&bank_no=<%=(bank_no.Text)%>">connect</a></p>

and receive from *.aspx like this

<td><%= Request.QueryString("case_no") %>於<%= Request.QueryString("bank_name") %></td>

in *.asp, it can't decode the string "bank_name" so the value is null why?

if the string is about number(ex:1234) it`s ok, but wrong when the string is chinses word(ex:中文)

Not a asp guru but you do not seem to have a query string parameter "bank_name" (only bank_no) when constructing the string in asp?
Yes you got the Query string wrong. As in your .aspx constructed url, the query string parameter is bank_no not bank_name

Pass Value from Code Behind to TextBox

Hi, I have a very basic question (I am a beginner)

How do I pass a value from the Code Behind to, say, a text box?

I've got this on my aspx page:

<asp:TextBoxID="TextBox1"runat="server"Text=strTestOnTextChanged="TextBox1_TextChanged"></asp:TextBox>

All I want to do is pass the value of strTest from the Code Behind to display in the Text Box. This is what I have in the code behind:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

String strText;strText ="Hello";

}

}

How can I get this to work?

It's very simple just try this

protectedvoid Page_Load(object sender,EventArgs e)

{

String strText;strText ="Hello";

TextBox1.Text =strText;

}


You are right...it is very simple;

Thanks for the help...and Iapologize for the very basic question;


don't forget to mark as answerd the post if it is.

Greets


Whenever you write something in PageLoad event, it should be executed with every postback event... So use IsPostBack event of page to identify page was post back or not ...

Pass value to function

Hello,
I have this function:
Sub Add_Menu_Item(ByVal Id As String, ByVal Text() As String)
And I am calling it this way:
Add_Menu_Item("home", {"contact","contacts"})
I get this error:
Compiler Error Message: BC30201: Expression expected.
Why?
Thanks,
Miguel
You have to use it like this:
Add_Menu_Item("home", new string() {"contact","contacts"})

Pass values in QueryString using VB.Net

Response.Redirect("http://localhost/WebApplication3/Forms/paymentprocessing.aspx?fname=+"

'Me.txtFirstName.Text"'", False)

how do i pass the text from a control in the querey string???

Dim myURL as string = "http://Localhost/WebApplication3/Forms/paymentprocessing.aspx?fname="

myURL = myURL & Me.txtFirstName.Text

Response.Redirect(myURL, False)

Saturday, March 24, 2012

Pass variable to another page

I have a calendar form that sends the inputted date back to a text box .
Using the GET method, I would like to pass the date as a variable to another
asp page. How do I do this?
Thanks.Hi Marti,
Not sure if I understand your question. But in ASP.Net 2.0 you have to
ability to do cross-page positing. So you can just do a postback with
value of that textbox to your other page.
More info:
http://www.dotnetjohn.com/articles.aspx?articleid=176
http://msdn2.microsoft.com/en-us/library/ms178139.aspx
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com
"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Marti wrote:
> I have a calendar form that sends the inputted date back to a text box .
> Using the GET method, I would like to pass the date as a variable to anoth
er
> asp page. How do I do this?
> Thanks.
>
Ward,
Thanks - That's exactly what I was looking for. I was using a different
method to pass values. I have tried using the postback method but to no
avail. Below is the source page I am working with, can you tell me what I
should have on my target page?
Thanks.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Cross Page PostBack</title>
</head>
<body>
<form name="form1" id="form1" runat="server">
<h3>Cross Page PostBack</h3>
Enter Search Term:
<asp:TextBox ID="SearchTerm" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Search"
PostBackUrl="posttarget.aspx" />
<br />
</form>
</body>
</html>
"Ward Bekker" <ward@.NOequanimitySPAM.nl> wrote in message
news:4405fc87$0$2027$9a622dc7@.news.kpnplanet.nl...
Hi Marti,
Not sure if I understand your question. But in ASP.Net 2.0 you have to
ability to do cross-page positing. So you can just do a postback with
value of that textbox to your other page.
More info:
http://www.dotnetjohn.com/articles.aspx?articleid=176
http://msdn2.microsoft.com/en-us/library/ms178139.aspx
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com
"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Marti wrote:
> I have a calendar form that sends the inputted date back to a text box .
> Using the GET method, I would like to pass the date as a variable to
another
> asp page. How do I do this?
> Thanks.
>
Ok, I think I know out the code isn't working. Don't have 2.0 installed.
I'll install the 2.0 framework and give the crosspage post back a try..
"Martin" <bmquiroz@.email.com> wrote in message
news:%23ItZRAYPGHA.3460@.TK2MSFTNGP15.phx.gbl...
Ward,
Thanks - That's exactly what I was looking for. I was using a different
method to pass values. I have tried using the postback method but to no
avail. Below is the source page I am working with, can you tell me what I
should have on my target page?
Thanks.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Cross Page PostBack</title>
</head>
<body>
<form name="form1" id="form1" runat="server">
<h3>Cross Page PostBack</h3>
Enter Search Term:
<asp:TextBox ID="SearchTerm" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Search"
PostBackUrl="posttarget.aspx" />
<br />
</form>
</body>
</html>
"Ward Bekker" <ward@.NOequanimitySPAM.nl> wrote in message
news:4405fc87$0$2027$9a622dc7@.news.kpnplanet.nl...
Hi Marti,
Not sure if I understand your question. But in ASP.Net 2.0 you have to
ability to do cross-page positing. So you can just do a postback with
value of that textbox to your other page.
More info:
http://www.dotnetjohn.com/articles.aspx?articleid=176
http://msdn2.microsoft.com/en-us/library/ms178139.aspx
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com
"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Marti wrote:
> I have a calendar form that sends the inputted date back to a text box .
> Using the GET method, I would like to pass the date as a variable to
another
> asp page. How do I do this?
> Thanks.
>

Pass variable to another page

I have a calendar form that sends the inputted date back to a text box .
Using the GET method, I would like to pass the date as a variable to another
asp page. How do I do this?

Thanks.Hi Marti,

Not sure if I understand your question. But in ASP.Net 2.0 you have to
ability to do cross-page positing. So you can just do a postback with
value of that textbox to your other page.

More info:
http://www.dotnetjohn.com/articles.aspx?articleid=176
http://msdn2.microsoft.com/en-us/library/ms178139.aspx

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx

Marti wrote:
> I have a calendar form that sends the inputted date back to a text box .
> Using the GET method, I would like to pass the date as a variable to another
> asp page. How do I do this?
> Thanks.
Ward,

Thanks - That's exactly what I was looking for. I was using a different
method to pass values. I have tried using the postback method but to no
avail. Below is the source page I am working with, can you tell me what I
should have on my target page?

Thanks.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Cross Page PostBack</title>
</head
<body>
<form name="form1" id="form1" runat="server">
<h3>Cross Page PostBack</h3>
Enter Search Term:
<asp:TextBox ID="SearchTerm" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Search"
PostBackUrl="posttarget.aspx" />
<br />
</form>
</body>
</html
"Ward Bekker" <ward@.NOequanimitySPAM.nl> wrote in message
news:4405fc87$0$2027$9a622dc7@.news.kpnplanet.nl...
Hi Marti,

Not sure if I understand your question. But in ASP.Net 2.0 you have to
ability to do cross-page positing. So you can just do a postback with
value of that textbox to your other page.

More info:
http://www.dotnetjohn.com/articles.aspx?articleid=176
http://msdn2.microsoft.com/en-us/library/ms178139.aspx

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx

Marti wrote:
> I have a calendar form that sends the inputted date back to a text box .
> Using the GET method, I would like to pass the date as a variable to
another
> asp page. How do I do this?
> Thanks.
Ok, I think I know out the code isn't working. Don't have 2.0 installed.
I'll install the 2.0 framework and give the crosspage post back a try..

"Martin" <bmquiroz@.email.com> wrote in message
news:%23ItZRAYPGHA.3460@.TK2MSFTNGP15.phx.gbl...
Ward,

Thanks - That's exactly what I was looking for. I was using a different
method to pass values. I have tried using the postback method but to no
avail. Below is the source page I am working with, can you tell me what I
should have on my target page?

Thanks.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Cross Page PostBack</title>
</head
<body>
<form name="form1" id="form1" runat="server">
<h3>Cross Page PostBack</h3>
Enter Search Term:
<asp:TextBox ID="SearchTerm" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Search"
PostBackUrl="posttarget.aspx" />
<br />
</form>
</body>
</html
"Ward Bekker" <ward@.NOequanimitySPAM.nl> wrote in message
news:4405fc87$0$2027$9a622dc7@.news.kpnplanet.nl...
Hi Marti,

Not sure if I understand your question. But in ASP.Net 2.0 you have to
ability to do cross-page positing. So you can just do a postback with
value of that textbox to your other page.

More info:
http://www.dotnetjohn.com/articles.aspx?articleid=176
http://msdn2.microsoft.com/en-us/library/ms178139.aspx

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx

Marti wrote:
> I have a calendar form that sends the inputted date back to a text box .
> Using the GET method, I would like to pass the date as a variable to
another
> asp page. How do I do this?
> Thanks.

passing 30+ parameters

i am developing a asp.net aplication, in that..Form1 has some 30 plus text input boxes.

i use a business logic to insert data into the database,

What will be the optimal way to pass all these parameters to BusinessLogic in a single function call?

Hi

I create a structure and fill up the details and then pass it to the business logic and this works very well for me.

I suggest, you try this approach.


Usually for most of my web apps I create a data access layer (DAL) that is a seperate DLL.

I have all my data modelled in objects and pass only the objects back and forth to the DAL. I sometime mix in the business logic layer (BLL) into the DAL as well depending on how complex the application is. One advantage to this is it is quite easy to slap on any type of a GUI onto you application since the core of the application lives is in the DAL or DAL & BLL.

It will make your life easier maintaining the code in the future as well.


so is it advicable to send them in object arrays

Yes.

You could use generics (templates) to pass them if you like.

List<yourObject> type.


sorry, i dont follow your last post. can you give a sample for say 6 diferrent objects

You can use something like the following:

List<String> myStringList = new List<String>();

myStringList.Add("String1");

myStringList.Add("String2");

Generic type will ensure that you are only inserting the String and not any other object. If you have different objects that you will be inserting you can use an ArrayList or better off List<object>.


List<String> myStringList = new List<String>();

myStringList.Add("Alpha");

myStringList.Add("11 Address");

what is the <String> there?Tongue Tied


String is a type. List<String> means that you are creating a list which will only contain string elements. So, if you have 30 textboxes you can iterate through the textboxes and populate the list. Later if you need to access the values of the textboxes you can put the list into a session variable and then access it on the next page.


List<String> myStringList = new List<String>();

creates a "container" called myStringList which can only host String object. You can put as many String object as you want and pass the List "container" itself as parameter. here is one example.

public ... function (List<string> inputList)
{
...

foreach (string currValue in inputList)
{
// iterate through the List

// Do something

}


return ...;
}


Is the List<String> objectIndexed.

How do i access the individual objects in the list?


It's very simple:

List<string> lstStrings = new List<string>();

lstStrings.Add("Test");

string sTemp = lstStrings[0];

or you could use a foreach

foreach (string sTemp in lstStrings)...


List<string> lstStrings = new List<string>();

i get this error when trying to use that construct

"Error 1 The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)"


add this to the top of your code behind file:

using System.Collections.Generic;


using System.Collections.Generic;using System.Collections.Generic;add this to the top of your code behind file:

using System.Collections.Generic;

Wednesday, March 21, 2012

Passing a parameter to another page

On one page I have a datagrid which is filled when the user selects some search criteria (e.g. surname or DoB) in different text fields and clicking on a button control.

The datagrid also contains a 'button column' which the user can use to edit and save changes to individual records to the db.

I use the following code to access the PK of the table in question as a parameter for my update query:

Dim strPatID As String = e.Item.Cells(0).Text

strSQL = "UPDATE blah "
strSQL = strSQL & "SET blah blah blah"
strSQL = strSQL & "WHERE patid = '" & strPatID & "'"

All of this works fine.

However, I also want users to be able to add records to a related table (which is at the many end of a relationship) based on the record they've selected from the datagrid. I've set up a 'hyperlink column' in the same datagrid which redirects them to another page where they'll be able to add data and save it. Fine so far.

The problem is of course, I need the patid as the foreign key to this second table. How can I pass this as a parameter to the second page? Am I doing this the right way or is there a better way to add records to related tables?

I hope I've made myself clear. Please let me know if you need additional information.

Thanks in advance for any help.

MoYou could pass it in the querystring to the new page:

DetailEntry.aspx?PatID=xxxxxx

On the second page, you can use Request.Querystring("PatID") to get the value
Thanks very much for the response Jim. I'll try it out.
Best regards to JimRoss:

In addition to using QueryString, you can also think of :

Session Variables as another solution, in addition to the other solutions.

regards

Friday, March 16, 2012

Passing a value from server side to client side

Im having a bit of a problem here, what I want to do is a user types
in data in a text box then I need to pass that data to the client side.
The problem Im having is I can't seem to get the value from the text
box be it a regular asp.net text box or even when I assign a value in a
hidden textbox I still can't seem to get the value. I thought using:
document.getElementbyID("Client_ID").innerText would get the value but
its not.
Any help will be greatly appreciated.
ThanksWhere is the textbox? Grid/DataList/Repeater? User control? Content page?

Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

<kimberly.walker@.consultant.comwrote in message
news:1152715225.255729.148180@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Im having a bit of a problem here, what I want to do is a user types
in data in a text box then I need to pass that data to the client side.
The problem Im having is I can't seem to get the value from the text
box be it a regular asp.net text box or even when I assign a value in a
hidden textbox I still can't seem to get the value. I thought using:
document.getElementbyID("Client_ID").innerText would get the value but
its not.
Any help will be greatly appreciated.
Thanks
>


Kimberly,

The first thing to check is whether or not you have the correct client id.
ViewSource on the page and double check what client id your control is being
rendered with.

Regards,

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche

<kimberly.walker@.consultant.comwrote in message
news:1152715225.255729.148180@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Im having a bit of a problem here, what I want to do is a user types
in data in a text box then I need to pass that data to the client side.
The problem Im having is I can't seem to get the value from the text
box be it a regular asp.net text box or even when I assign a value in a
hidden textbox I still can't seem to get the value. I thought using:
document.getElementbyID("Client_ID").innerText would get the value but
its not.
Any help will be greatly appreciated.
Thanks
>


Hi Eliyahu,
The text box is an asp.net text on a user control

Eliyahu Goldin wrote:

Quote:

Originally Posted by

Where is the textbox? Grid/DataList/Repeater? User control? Content page?
>
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
>
<kimberly.walker@.consultant.comwrote in message
news:1152715225.255729.148180@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Im having a bit of a problem here, what I want to do is a user types
in data in a text box then I need to pass that data to the client side.
The problem Im having is I can't seem to get the value from the text
box be it a regular asp.net text box or even when I assign a value in a
hidden textbox I still can't seem to get the value. I thought using:
document.getElementbyID("Client_ID").innerText would get the value but
its not.
Any help will be greatly appreciated.
Thanks


You should use the textbox ClientID property. You need to pass it from
server to client. If you do it in a hidden input control, it may look like:

<input type="hidden" id="clientId" runat="server"/>
...
var clientId=document.getElementById("clientId").value;
...
myText=document.getElementById(clientId).value

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

<kimberly.walker@.consultant.comwrote in message
news:1152759520.814547.273090@.m79g2000cwm.googlegr oups.com...

Quote:

Originally Posted by

Hi Eliyahu,
The text box is an asp.net text on a user control
>
Eliyahu Goldin wrote:

Quote:

Originally Posted by

>Where is the textbox? Grid/DataList/Repeater? User control? Content page?
>>
>Eliyahu Goldin,
>Software Developer & Consultant
>Microsoft MVP [ASP.NET]
>>
><kimberly.walker@.consultant.comwrote in message
>news:1152715225.255729.148180@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

Im having a bit of a problem here, what I want to do is a user types
in data in a text box then I need to pass that data to the client side.
The problem Im having is I can't seem to get the value from the text
box be it a regular asp.net text box or even when I assign a value in a
hidden textbox I still can't seem to get the value. I thought using:
document.getElementbyID("Client_ID").innerText would get the value but
its not.
Any help will be greatly appreciated.
Thanks
>


>

Passing A Value To Server

Basic Web Form... A few text boxes and a checkbox - and a card reader...
The effect I want to accomplish is this:
The basic credit card fields are there and can be filled out. But if the
user swipes the card, I want to fill out the fields automatically and make
them read only. (So far I can do this.)
But I also want a checkbox to appear that indicates the card was swiped.
The user can clear the checkbox, re-enabling the fields so they can be
edited, but then I will no longer consider the data as being swiped. I want
the check box to disappear if they clear it.
Using server controls, if I create a checkbox, but make it not visible, then
it's not available at the client side to work with from client side code.
So I would need to send some flag back to the server to indicate a post back
and have the page re-rendered properly. But how do send info to the server
like that without having a visible control to attach the data to?
(Does this make any sense? Not sure if I'm explaining it well.)
Is there a way to send a value back to the server, in a postback, where the
data is not a property of a server control that's tracking viewstate? The
session object is only available on the server side right?
Any guidance here is appreciated. Thanks.
Jerryto send additional value to server , one commonly used method is
a HiddenControl (you will access it like Request.Forms["HiddenContrlName"]
from code behind)
or a TextBox Webcontrol with size 0 or attribute style='display:none' ..
But if the only purpose of post back is to display/check the checkbox ,
probabaly a better approach is to do the display/check in the client side
javascript ..
Instead of settign Visibility=False, you would just add an attribute to
make it hidden , but still available at client code
CheckBoxName.Attributes.Add("style='display:none'")
"Jerry Camel" wrote:

> Basic Web Form... A few text boxes and a checkbox - and a card reader...
> The effect I want to accomplish is this:
> The basic credit card fields are there and can be filled out. But if the
> user swipes the card, I want to fill out the fields automatically and make
> them read only. (So far I can do this.)
> But I also want a checkbox to appear that indicates the card was swiped.
> The user can clear the checkbox, re-enabling the fields so they can be
> edited, but then I will no longer consider the data as being swiped. I wa
nt
> the check box to disappear if they clear it.
> Using server controls, if I create a checkbox, but make it not visible, th
en
> it's not available at the client side to work with from client side code.
> So I would need to send some flag back to the server to indicate a post ba
ck
> and have the page re-rendered properly. But how do send info to the serve
r
> like that without having a visible control to attach the data to?
> (Does this make any sense? Not sure if I'm explaining it well.)
> Is there a way to send a value back to the server, in a postback, where th
e
> data is not a property of a server control that's tracking viewstate? The
> session object is only available on the server side right?
> Any guidance here is appreciated. Thanks.
> Jerry
>
>
Okay... I can have the checkbox on the form and available with 'Display:
None'...
But I can't seem to find the proper syntax to change the display state and
make it visible on the client side...
Thanks.
"Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> to send additional value to server , one commonly used method is
> a HiddenControl (you will access it like Request.Forms["HiddenContrlName"]
> from code behind)
> or a TextBox Webcontrol with size 0 or attribute style='display:none' ..
> But if the only purpose of post back is to display/check the checkbox ,
> probabaly a better approach is to do the display/check in the client side
> javascript ..
> Instead of settign Visibility=False, you would just add an attribute to
> make it hidden , but still available at client code
> CheckBoxName.Attributes.Add("style='display:none'")
>
> "Jerry Camel" wrote:
>
reader...
the
make
want
then
code.
back
server
the
The
Syntax to display ?
document.getElementById("CheckBoxClientName").style.display='' ;
document.getElementById("CheckBoxClientName").Checked = true;
this may help...
http://www.w3schools.com/htmldom/dom_obj_checkbox.asp
http://www.w3schools.com/htmldom/do...tyle.asp#layout
"Jerry Camel" wrote:

> Okay... I can have the checkbox on the form and available with 'Display:
> None'...
> But I can't seem to find the proper syntax to change the display state and
> make it visible on the client side...
> Thanks.
>
> "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> reader...
> the
> make
> want
> then
> code.
> back
> server
> the
> The
>
>
Thanks, but this doesn't seem to have any effect. I tried changing the
style.display property to all kinds of values, but the checkbox never
appears...
Jerry
"Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
news:514C006A-51EE-42B4-938C-506D452587A4@.microsoft.com...
> Syntax to display ?
> document.getElementById("CheckBoxClientName").style.display='' ;
> document.getElementById("CheckBoxClientName").Checked = true;
> this may help...
> http://www.w3schools.com/htmldom/dom_obj_checkbox.asp
> http://www.w3schools.com/htmldom/do...tyle.asp#layout
>
> "Jerry Camel" wrote:
>
'Display:
and
Request.Forms["HiddenContrlName"]
..
,
side
to
if
and
swiped.
be
I
visible,
post
where
viewstate?
Obviously there is some thing not right other than the syntax.. :) .. Is
there any javascript error when you call the function to display the
checkbox?...
if still no luck, you may want to create a simple HTML page with only
following code in it...
<INPUT TYPE=checkbox ID=chk1 style='display:hidden'>
<INPUT TYPE=button ID=btn1 onClick="toggle()" value="Click to Toggle
Display" >
<script>
function toggle(id)
{
el = document.getElementById("chk1");
var display = el.style.display ? '' : 'none';
el.style.display = display;
}
</script>
Once this works, you can compare with the HTML your aspx generated and that
may help in finding the issue..
This link got a working sample... with code...pls see if this helps..
http://www.sam-i-am.com/work/sandbo...le_display.html
"Jerry Camel" wrote:

> Thanks, but this doesn't seem to have any effect. I tried changing the
> style.display property to all kinds of values, but the checkbox never
> appears...
> Jerry
> "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> news:514C006A-51EE-42B4-938C-506D452587A4@.microsoft.com...
> 'Display:
> and
> Request.Forms["HiddenContrlName"]
> ...
> ,
> side
> to
> if
> and
> swiped.
> be
> I
> visible,
> post
> where
> viewstate?
>
>
I'll play with it. Thanks for your help. I was trying to use vbscript, but
I may have to switch to javascript...
Jerry
"Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
news:54BF5C69-C844-40FF-A427-409FEAED12EE@.microsoft.com...
> Obviously there is some thing not right other than the syntax.. :) .. Is
> there any javascript error when you call the function to display the
> checkbox?...
> if still no luck, you may want to create a simple HTML page with only
> following code in it...
> <INPUT TYPE=checkbox ID=chk1 style='display:hidden'>
> <INPUT TYPE=button ID=btn1 onClick="toggle()" value="Click to Toggle
> Display" >
> <script>
> function toggle(id)
> {
> el = document.getElementById("chk1");
> var display = el.style.display ? '' : 'none';
> el.style.display = display;
> }
> </script>
> Once this works, you can compare with the HTML your aspx generated and
that
> may help in finding the issue..
> This link got a working sample... with code...pls see if this helps..
> http://www.sam-i-am.com/work/sandbo...le_display.html
>
> "Jerry Camel" wrote:
>
document.getElementById("CheckBoxClientName").style.display='' ;
true;
state
message
style='display:none'
checkbox
client
attribute
But
automatically
can
swiped.
side
a
the
to?
postback,

Passing A Value To Server

Basic Web Form... A few text boxes and a checkbox - and a card reader...
The effect I want to accomplish is this:

The basic credit card fields are there and can be filled out. But if the
user swipes the card, I want to fill out the fields automatically and make
them read only. (So far I can do this.)

But I also want a checkbox to appear that indicates the card was swiped.
The user can clear the checkbox, re-enabling the fields so they can be
edited, but then I will no longer consider the data as being swiped. I want
the check box to disappear if they clear it.

Using server controls, if I create a checkbox, but make it not visible, then
it's not available at the client side to work with from client side code.
So I would need to send some flag back to the server to indicate a post back
and have the page re-rendered properly. But how do send info to the server
like that without having a visible control to attach the data to?

(Does this make any sense? Not sure if I'm explaining it well.)

Is there a way to send a value back to the server, in a postback, where the
data is not a property of a server control that's tracking viewstate? The
session object is only available on the server side right?

Any guidance here is appreciated. Thanks.

Jerryto send additional value to server , one commonly used method is

a HiddenControl (you will access it like Request.Forms["HiddenContrlName"]
from code behind)

or a TextBox Webcontrol with size 0 or attribute style='display:none' ..

But if the only purpose of post back is to display/check the checkbox ,
probabaly a better approach is to do the display/check in the client side
javascript ..

Instead of settign Visibility=False, you would just add an attribute to
make it hidden , but still available at client code

CheckBoxName.Attributes.Add("style='display:none'")

"Jerry Camel" wrote:

> Basic Web Form... A few text boxes and a checkbox - and a card reader...
> The effect I want to accomplish is this:
> The basic credit card fields are there and can be filled out. But if the
> user swipes the card, I want to fill out the fields automatically and make
> them read only. (So far I can do this.)
> But I also want a checkbox to appear that indicates the card was swiped.
> The user can clear the checkbox, re-enabling the fields so they can be
> edited, but then I will no longer consider the data as being swiped. I want
> the check box to disappear if they clear it.
> Using server controls, if I create a checkbox, but make it not visible, then
> it's not available at the client side to work with from client side code.
> So I would need to send some flag back to the server to indicate a post back
> and have the page re-rendered properly. But how do send info to the server
> like that without having a visible control to attach the data to?
> (Does this make any sense? Not sure if I'm explaining it well.)
> Is there a way to send a value back to the server, in a postback, where the
> data is not a property of a server control that's tracking viewstate? The
> session object is only available on the server side right?
> Any guidance here is appreciated. Thanks.
> Jerry
>
Okay... I can have the checkbox on the form and available with 'Display:
None'...

But I can't seem to find the proper syntax to change the display state and
make it visible on the client side...

Thanks.

"Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> to send additional value to server , one commonly used method is
> a HiddenControl (you will access it like Request.Forms["HiddenContrlName"]
> from code behind)
> or a TextBox Webcontrol with size 0 or attribute style='display:none' ..
> But if the only purpose of post back is to display/check the checkbox ,
> probabaly a better approach is to do the display/check in the client side
> javascript ..
> Instead of settign Visibility=False, you would just add an attribute to
> make it hidden , but still available at client code
> CheckBoxName.Attributes.Add("style='display:none'")
>
> "Jerry Camel" wrote:
> > Basic Web Form... A few text boxes and a checkbox - and a card
reader...
> > The effect I want to accomplish is this:
> > The basic credit card fields are there and can be filled out. But if
the
> > user swipes the card, I want to fill out the fields automatically and
make
> > them read only. (So far I can do this.)
> > But I also want a checkbox to appear that indicates the card was swiped.
> > The user can clear the checkbox, re-enabling the fields so they can be
> > edited, but then I will no longer consider the data as being swiped. I
want
> > the check box to disappear if they clear it.
> > Using server controls, if I create a checkbox, but make it not visible,
then
> > it's not available at the client side to work with from client side
code.
> > So I would need to send some flag back to the server to indicate a post
back
> > and have the page re-rendered properly. But how do send info to the
server
> > like that without having a visible control to attach the data to?
> > (Does this make any sense? Not sure if I'm explaining it well.)
> > Is there a way to send a value back to the server, in a postback, where
the
> > data is not a property of a server control that's tracking viewstate?
The
> > session object is only available on the server side right?
> > Any guidance here is appreciated. Thanks.
> > Jerry
Syntax to display ?

document.getElementById("CheckBoxClientName").style.display='' ;
document.getElementById("CheckBoxClientName").Checked = true;

this may help...
http://www.w3schools.com/htmldom/dom_obj_checkbox.asp
http://www.w3schools.com/htmldom/do...tyle.asp#layout

"Jerry Camel" wrote:

> Okay... I can have the checkbox on the form and available with 'Display:
> None'...
> But I can't seem to find the proper syntax to change the display state and
> make it visible on the client side...
> Thanks.
>
> "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> > to send additional value to server , one commonly used method is
> > a HiddenControl (you will access it like Request.Forms["HiddenContrlName"]
> > from code behind)
> > or a TextBox Webcontrol with size 0 or attribute style='display:none' ..
> > But if the only purpose of post back is to display/check the checkbox ,
> > probabaly a better approach is to do the display/check in the client side
> > javascript ..
> > Instead of settign Visibility=False, you would just add an attribute to
> > make it hidden , but still available at client code
> > CheckBoxName.Attributes.Add("style='display:none'")
> > "Jerry Camel" wrote:
> > > Basic Web Form... A few text boxes and a checkbox - and a card
> reader...
> > > The effect I want to accomplish is this:
> > > > The basic credit card fields are there and can be filled out. But if
> the
> > > user swipes the card, I want to fill out the fields automatically and
> make
> > > them read only. (So far I can do this.)
> > > > But I also want a checkbox to appear that indicates the card was swiped.
> > > The user can clear the checkbox, re-enabling the fields so they can be
> > > edited, but then I will no longer consider the data as being swiped. I
> want
> > > the check box to disappear if they clear it.
> > > > Using server controls, if I create a checkbox, but make it not visible,
> then
> > > it's not available at the client side to work with from client side
> code.
> > > So I would need to send some flag back to the server to indicate a post
> back
> > > and have the page re-rendered properly. But how do send info to the
> server
> > > like that without having a visible control to attach the data to?
> > > > (Does this make any sense? Not sure if I'm explaining it well.)
> > > > Is there a way to send a value back to the server, in a postback, where
> the
> > > data is not a property of a server control that's tracking viewstate?
> The
> > > session object is only available on the server side right?
> > > > Any guidance here is appreciated. Thanks.
> > > > Jerry
> > > >
Thanks, but this doesn't seem to have any effect. I tried changing the
style.display property to all kinds of values, but the checkbox never
appears...

Jerry

"Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
news:514C006A-51EE-42B4-938C-506D452587A4@.microsoft.com...
> Syntax to display ?
> document.getElementById("CheckBoxClientName").style.display='' ;
> document.getElementById("CheckBoxClientName").Checked = true;
> this may help...
> http://www.w3schools.com/htmldom/dom_obj_checkbox.asp
> http://www.w3schools.com/htmldom/do...tyle.asp#layout
>
> "Jerry Camel" wrote:
> > Okay... I can have the checkbox on the form and available with
'Display:
> > None'...
> > But I can't seem to find the proper syntax to change the display state
and
> > make it visible on the client side...
> > Thanks.
> > "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> > news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> > > to send additional value to server , one commonly used method is
> > > > a HiddenControl (you will access it like
Request.Forms["HiddenContrlName"]
> > > from code behind)
> > > > or a TextBox Webcontrol with size 0 or attribute style='display:none'
...
> > > > But if the only purpose of post back is to display/check the checkbox
,
> > > probabaly a better approach is to do the display/check in the client
side
> > > javascript ..
> > > > Instead of settign Visibility=False, you would just add an attribute
to
> > > make it hidden , but still available at client code
> > > > CheckBoxName.Attributes.Add("style='display:none'")
> > > > > > "Jerry Camel" wrote:
> > > > > Basic Web Form... A few text boxes and a checkbox - and a card
> > reader...
> > > > The effect I want to accomplish is this:
> > > > > > The basic credit card fields are there and can be filled out. But
if
> > the
> > > > user swipes the card, I want to fill out the fields automatically
and
> > make
> > > > them read only. (So far I can do this.)
> > > > > > But I also want a checkbox to appear that indicates the card was
swiped.
> > > > The user can clear the checkbox, re-enabling the fields so they can
be
> > > > edited, but then I will no longer consider the data as being swiped.
I
> > want
> > > > the check box to disappear if they clear it.
> > > > > > Using server controls, if I create a checkbox, but make it not
visible,
> > then
> > > > it's not available at the client side to work with from client side
> > code.
> > > > So I would need to send some flag back to the server to indicate a
post
> > back
> > > > and have the page re-rendered properly. But how do send info to the
> > server
> > > > like that without having a visible control to attach the data to?
> > > > > > (Does this make any sense? Not sure if I'm explaining it well.)
> > > > > > Is there a way to send a value back to the server, in a postback,
where
> > the
> > > > data is not a property of a server control that's tracking
viewstate?
> > The
> > > > session object is only available on the server side right?
> > > > > > Any guidance here is appreciated. Thanks.
> > > > > > Jerry
> > > > > >
Obviously there is some thing not right other than the syntax.. :) .. Is
there any javascript error when you call the function to display the
checkbox?...

if still no luck, you may want to create a simple HTML page with only
following code in it...

<INPUT TYPE=checkbox ID=chk1 style='display:hidden'>
<INPUT TYPE=button ID=btn1 onClick="toggle()" value="Click to Toggle
Display"
<script>
function toggle(id)
{
el = document.getElementById("chk1");
var display = el.style.display ? '' : 'none';
el.style.display = display;
}
</script
Once this works, you can compare with the HTML your aspx generated and that
may help in finding the issue..

This link got a working sample... with code...pls see if this helps..
http://www.sam-i-am.com/work/sandbo...le_display.html

"Jerry Camel" wrote:

> Thanks, but this doesn't seem to have any effect. I tried changing the
> style.display property to all kinds of values, but the checkbox never
> appears...
> Jerry
> "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> news:514C006A-51EE-42B4-938C-506D452587A4@.microsoft.com...
> > Syntax to display ?
> > document.getElementById("CheckBoxClientName").style.display='' ;
> > document.getElementById("CheckBoxClientName").Checked = true;
> > this may help...
> > http://www.w3schools.com/htmldom/dom_obj_checkbox.asp
> > http://www.w3schools.com/htmldom/do...tyle.asp#layout
> > "Jerry Camel" wrote:
> > > Okay... I can have the checkbox on the form and available with
> 'Display:
> > > None'...
> > > > But I can't seem to find the proper syntax to change the display state
> and
> > > make it visible on the client side...
> > > > Thanks.
> > > > > "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> > > news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> > > > to send additional value to server , one commonly used method is
> > > > > > a HiddenControl (you will access it like
> Request.Forms["HiddenContrlName"]
> > > > from code behind)
> > > > > > or a TextBox Webcontrol with size 0 or attribute style='display:none'
> ...
> > > > > > But if the only purpose of post back is to display/check the checkbox
> ,
> > > > probabaly a better approach is to do the display/check in the client
> side
> > > > javascript ..
> > > > > > Instead of settign Visibility=False, you would just add an attribute
> to
> > > > make it hidden , but still available at client code
> > > > > > CheckBoxName.Attributes.Add("style='display:none'")
> > > > > > > > > > "Jerry Camel" wrote:
> > > > > > > Basic Web Form... A few text boxes and a checkbox - and a card
> > > reader...
> > > > > The effect I want to accomplish is this:
> > > > > > > > The basic credit card fields are there and can be filled out. But
> if
> > > the
> > > > > user swipes the card, I want to fill out the fields automatically
> and
> > > make
> > > > > them read only. (So far I can do this.)
> > > > > > > > But I also want a checkbox to appear that indicates the card was
> swiped.
> > > > > The user can clear the checkbox, re-enabling the fields so they can
> be
> > > > > edited, but then I will no longer consider the data as being swiped.
> I
> > > want
> > > > > the check box to disappear if they clear it.
> > > > > > > > Using server controls, if I create a checkbox, but make it not
> visible,
> > > then
> > > > > it's not available at the client side to work with from client side
> > > code.
> > > > > So I would need to send some flag back to the server to indicate a
> post
> > > back
> > > > > and have the page re-rendered properly. But how do send info to the
> > > server
> > > > > like that without having a visible control to attach the data to?
> > > > > > > > (Does this make any sense? Not sure if I'm explaining it well.)
> > > > > > > > Is there a way to send a value back to the server, in a postback,
> where
> > > the
> > > > > data is not a property of a server control that's tracking
> viewstate?
> > > The
> > > > > session object is only available on the server side right?
> > > > > > > > Any guidance here is appreciated. Thanks.
> > > > > > > > Jerry
> > > > > > > > > > > > >
I'll play with it. Thanks for your help. I was trying to use vbscript, but
I may have to switch to javascript...

Jerry

"Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
news:54BF5C69-C844-40FF-A427-409FEAED12EE@.microsoft.com...
> Obviously there is some thing not right other than the syntax.. :) .. Is
> there any javascript error when you call the function to display the
> checkbox?...
> if still no luck, you may want to create a simple HTML page with only
> following code in it...
> <INPUT TYPE=checkbox ID=chk1 style='display:hidden'>
> <INPUT TYPE=button ID=btn1 onClick="toggle()" value="Click to Toggle
> Display" >
> <script>
> function toggle(id)
> {
> el = document.getElementById("chk1");
> var display = el.style.display ? '' : 'none';
> el.style.display = display;
> }
> </script>
> Once this works, you can compare with the HTML your aspx generated and
that
> may help in finding the issue..
> This link got a working sample... with code...pls see if this helps..
> http://www.sam-i-am.com/work/sandbo...le_display.html
>
> "Jerry Camel" wrote:
> > Thanks, but this doesn't seem to have any effect. I tried changing the
> > style.display property to all kinds of values, but the checkbox never
> > appears...
> > Jerry
> > "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in message
> > news:514C006A-51EE-42B4-938C-506D452587A4@.microsoft.com...
> > > Syntax to display ?
> > document.getElementById("CheckBoxClientName").style.display='' ;
> > > document.getElementById("CheckBoxClientName").Checked =
true;
> > > > this may help...
> > > http://www.w3schools.com/htmldom/dom_obj_checkbox.asp
> > > http://www.w3schools.com/htmldom/do...tyle.asp#layout
> > > > > > "Jerry Camel" wrote:
> > > > > Okay... I can have the checkbox on the form and available with
> > 'Display:
> > > > None'...
> > > > > > But I can't seem to find the proper syntax to change the display
state
> > and
> > > > make it visible on the client side...
> > > > > > Thanks.
> > > > > > > > "Sreejith Ram" <SreejithRam@.discussions.microsoft.com> wrote in
message
> > > > news:431FA795-5920-4B2C-81E1-98224CD89497@.microsoft.com...
> > > > > to send additional value to server , one commonly used method is
> > > > > > > > a HiddenControl (you will access it like
> > Request.Forms["HiddenContrlName"]
> > > > > from code behind)
> > > > > > > > or a TextBox Webcontrol with size 0 or attribute
style='display:none'
> > ...
> > > > > > > > But if the only purpose of post back is to display/check the
checkbox
> > ,
> > > > > probabaly a better approach is to do the display/check in the
client
> > side
> > > > > javascript ..
> > > > > > > > Instead of settign Visibility=False, you would just add an
attribute
> > to
> > > > > make it hidden , but still available at client code
> > > > > > > > CheckBoxName.Attributes.Add("style='display:none'")
> > > > > > > > > > > > > > "Jerry Camel" wrote:
> > > > > > > > > Basic Web Form... A few text boxes and a checkbox - and a card
> > > > reader...
> > > > > > The effect I want to accomplish is this:
> > > > > > > > > > The basic credit card fields are there and can be filled out.
But
> > if
> > > > the
> > > > > > user swipes the card, I want to fill out the fields
automatically
> > and
> > > > make
> > > > > > them read only. (So far I can do this.)
> > > > > > > > > > But I also want a checkbox to appear that indicates the card was
> > swiped.
> > > > > > The user can clear the checkbox, re-enabling the fields so they
can
> > be
> > > > > > edited, but then I will no longer consider the data as being
swiped.
> > I
> > > > want
> > > > > > the check box to disappear if they clear it.
> > > > > > > > > > Using server controls, if I create a checkbox, but make it not
> > visible,
> > > > then
> > > > > > it's not available at the client side to work with from client
side
> > > > code.
> > > > > > So I would need to send some flag back to the server to indicate
a
> > post
> > > > back
> > > > > > and have the page re-rendered properly. But how do send info to
the
> > > > server
> > > > > > like that without having a visible control to attach the data
to?
> > > > > > > > > > (Does this make any sense? Not sure if I'm explaining it well.)
> > > > > > > > > > Is there a way to send a value back to the server, in a
postback,
> > where
> > > > the
> > > > > > data is not a property of a server control that's tracking
> > viewstate?
> > > > The
> > > > > > session object is only available on the server side right?
> > > > > > > > > > Any guidance here is appreciated. Thanks.
> > > > > > > > > > Jerry
> > > > > > > > > > > > > > > > > >

passing a value to another page in C#?

I have a master page with a label on it and i would like to set the text of that label from my other pages programatically. Basically I have tried to access the control directly, and also created a public method in the master page that takes in a string value and sets it to the control. However from say the default page, I cannot access that public method. How can I pass the value to the master page so that it sets the aspnet control text?

I have also tried making a public string variable, and while in the pageload having it set the text for the label. From the default page, in the pageload I tried to set the value, but I cannot. Any suggestions? Thanks.

Have you tried to add a Public Property in your MasterPages that returns the Label?

This way you can access the Label through any content page!

HTH,

regards


Hello,
If you are talking about the Master and Content pages, then i have a small information for you. You can work upon it and find out the details of it.

The Content page can access the Master Page through the Keyword "Master". So u can search the control from the master using Master.FindControl() and set its value.

Hope this works for you.

Az.
can you show me an example? I am not sure of what you are saying. Thanks.
what does that findcontrol method return?

If you have a label in your master page called Label1 and a textbox on your default page called Textbox1, then you could set the label with the contents of the textbox with this code:

protected void Button1_Click(object sender, EventArgs e) { ((Label)Master.FindControl("Label1")).Text = TextBox1.Text; }
 

The Master object is a property in the page object that stores the master page for the content page. FindControl returns a control from the page with an ID that matches the string passed as a parameter. The control that is returned from FindControl must be cast to Label to get the Text property.

This code allows you to set the value of the label in the master page, but that value will not persist to other content pages that use the same master page.


It is better to use a property, than the casting one!

Suppose you have changed the name of the Label in the master page, then you will have to go back to all your content pages and change the label name, but in the Master Page using a property, you could change the control name, and keep the property name the same!

HTH,

Regards


Well the main reason for not setting the label.text property in the master page is that it needs to be dynamic. The text of that label will be set on the page_load of the page using the master template. If i set it in the master template, I cannot change it dynamically from the aspx page. That findcontrol method casted worked great however. Thank you!

Please check my post again. I didn't say casting doesn't work!

I said watch out to a drawback when using Cast, which happens if you change the Control Name in the master Page!

HTH,

Regards


Hi ,

Can you show me - or point me to any ariticle(s) on, how to pass values from content pages to master pages after the properties are set in the master pages?

Example:

Say I have a text box id="txt1"

In the master page code behid we would have something like

Private _txt as string

Public Property thisText As String
Get
Return _txt
End Get
Set
_txt = value
End Set
End property

Me.txt1.text = thisText

I hope I am right so far...

The question is: How would I pass values for 'thisText' from different content pages.

Thanks.


samirayes:

*snipped*

I hope I am right so far...

The question is: How would I pass values for 'thisText' from different content pages.

Master.thisText = "foo"

Passing an '&' as part of the parameter's value in a query string

I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?

Thanks.

--
moondaddy@dotnet.itags.org.newsgroup.nospammoondaddy wrote:

Quote:

Originally Posted by

I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?
>
Thanks.


Use the encodeURIComponent function to encode the value that you put in
the URL.

You should do this for any values that you put in an URL that might
contain characters that needs encoding.

--
Gran Andersson
_____
http://www.guffa.com
On Sep 12, 9:19 am, "moondaddy" <moonda...@.newsgroup.nospamwrote:

Quote:

Originally Posted by

I have a situation where I will collect text from a textbox and pass that
text as one of the parameters in another pages query string. the problem is
that if the user types in a '&' as part of the text message, the page being
called thinks the '&' is parsing out another parameter. Using JavaScript,
what should I do to pass the entire message in the query string?
>


& = %26
Alexey Smirnov wrote:

Quote:

Originally Posted by

On Sep 12, 9:19 am, "moondaddy" <moonda...@.newsgroup.nospamwrote:

Quote:

Originally Posted by

>I have a situation where I will collect text from a textbox and pass that
>text as one of the parameters in another pages query string. the problem is
>that if the user types in a '&' as part of the text message, the page being
>called thinks the '&' is parsing out another parameter. Using JavaScript,
>what should I do to pass the entire message in the query string?
>>


>
& = %26
>


That is correct, but that only solves the problem with that specific
character. There are several other characters that are not valid in a
value in a query string, like spaces for example.

--
Gran Andersson
_____
http://www.guffa.com
Thanks!

encodeURIComponent worked perfect.

"Gran Andersson" <guffa@.guffa.comwrote in message
news:uFyGU9Q9HHA.980@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

moondaddy wrote:

Quote:

Originally Posted by

>I have a situation where I will collect text from a textbox and pass that
>text as one of the parameters in another pages query string. the problem
>is that if the user types in a '&' as part of the text message, the page
>being called thinks the '&' is parsing out another parameter. Using
>JavaScript, what should I do to pass the entire message in the query
>string?
>>
>Thanks.


>
Use the encodeURIComponent function to encode the value that you put in
the URL.
>
You should do this for any values that you put in an URL that might
contain characters that needs encoding.
>
--
Gran Andersson
_____
http://www.guffa.com