473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Hidden control problem

Hello!

I am working with 2 webforms. The first webform has a 2 weborm textboxes
that I use as a placeholders. The second webform is a popup window that has a
DataGrid in it. The DataGrid has 2 columns (Vendor Name and Vendor No.) When
the user clicks at a Datagird cell, the Vendor Name and Vendor No. are passed
to the first webform's 2 textboxes. But only the Vendor Name should be
visible. I therefore changed the Vendor No. textbox's Visible property to
False. But now the Vendor No. is no longer being retrieved by the first
webform. Should I use a different control? Suggestions? Thanks in advance.
Below is the code for the second webform (popup window):

public void DataGridEventHandler( object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Select_Vendor_No" || e.CommandName
"Select_Vendor_Name")
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';opener.document.Form1.txtVend orNo.value='"+vendorNo+"';window.close();";
}
}

private void DataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';
opener.document.Form1.txtVendorNo.value='"+vendorN o+"'; window.close();";
LinkButton lnk;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType ==
ListItemType.Item)
{
lnk = (LinkButton)e.Item.FindControl("lnkBut");
lnk.Attributes.Add("onclick", script);
}
}

Below is the code for the first webform:

private void btnSearch_Click(object sender, System.EventArgs e)
{
string vendorName = txtVendorName.Text;
string vendorNo = txtVendorNo.Text;
.........
}

Nov 16 '05 #1
1 2990
You don't show how you are setting the visible property to false but I am
going to assume you're doing it in your code behind. When you set visible
to false in code behind, the control isn't rendered to the HTML page.

To make your Vender No textbox not visible but still have it contain a
value, do it like this:

txtVendorNo.Style["DISPLAY"] = "none";

then to display it again:

txtVendorNo.Style["DISPLAY"] = "block";

or

txtVendorNo.Style.Remove("DISPLAY");

HTH

DalePres
MCAD, MCDBA, MCSE
"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
Hello!

I am working with 2 webforms. The first webform has a 2 weborm textboxes
that I use as a placeholders. The second webform is a popup window that
has a
DataGrid in it. The DataGrid has 2 columns (Vendor Name and Vendor No.)
When
the user clicks at a Datagird cell, the Vendor Name and Vendor No. are
passed
to the first webform's 2 textboxes. But only the Vendor Name should be
visible. I therefore changed the Vendor No. textbox's Visible property to
False. But now the Vendor No. is no longer being retrieved by the first
webform. Should I use a different control? Suggestions? Thanks in advance.
Below is the code for the second webform (popup window):

public void DataGridEventHandler( object sender, DataGridCommandEventArgs
e)
{
if (e.CommandName == "Select_Vendor_No" || e.CommandName
"Select_Vendor_Name")
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';opener.document.Form1.txtVend orNo.value='"+vendorNo+"';window.close();";
}
}

private void DataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';
opener.document.Form1.txtVendorNo.value='"+vendorN o+"'; window.close();";
LinkButton lnk;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType ==
ListItemType.Item)
{
lnk = (LinkButton)e.Item.FindControl("lnkBut");
lnk.Attributes.Add("onclick", script);
}
}

Below is the code for the first webform:

private void btnSearch_Click(object sender, System.EventArgs e)
{
string vendorName = txtVendorName.Text;
string vendorNo = txtVendorNo.Text;
.........
}

Nov 16 '05 #2

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

Similar topics

1
by: aquimr | last post by:
Hi, I'm using input hidden control's value in the javascript function. same code is working fine on all other browser except a specific version of safari(i.e.: MAC OS 10.3.7 and Safari 1.2.4)....
1
by: Rob Meade | last post by:
Hi all, I have a loop in my code which builds the controls on the page. I at one stage need to add some hidden input controls dynamically, I have achieved this, and I have set their...
2
by: Guadala Harry | last post by:
In an aspx file I have declared a hidden field like this: <input id="hTestVal" type=hidden value="-1" runat="server"> Defined in the code-behind like this: protected...
4
by: Ian Cox | last post by:
I have a web form that contains a Datagrid. This grid has a number of columns, one of which contains a text box and validator for that text box. Everything works fine, when I press the "Save"...
4
by: Magnus Blomberg | last post by:
Hello! I have a problem when using a hidden field to send a value to the server. Below you can see my code in simplyfied versions. What I'm trying to do is: 1. The user browses for a picture...
2
by: UJ | last post by:
I have an aspx page that does some database look ups on the initial load. I then need to do stuff later after an autopostback based on some of the values. So I put some variables in input variables...
2
by: cnickl | last post by:
I have the following problem: I’m creating a hidden control dynamically in the page_load event handler using the following code C#: .. HtmlInputHidden Hidden1 = new HtmlInputHidden();...
6
by: Bill Cohagan | last post by:
Is it possible to have a validation control whose ControlToValidate is in fact a hidden control? When I try this I find that the validator apparently does not fire. If I make the control...
3
by: ThunderMusic | last post by:
Hi, I have a custom control that draws many thing on the screen including a hidden field. This hidden field's value is modified through client code. What I want to do is the following : When there...
1
by: dawidg | last post by:
I have an asp.net page with viewstate disabled. I have a control on the page that dynamically creates controls inside itself, no viewstate. The controls aren't created in Init, but in Load. With...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.