Hidden control problem

G

Guest

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:blush:pener.document.Form1.txtVendorName.value='"+vendorName+"';opener.document.Form1.txtVendorNo.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:blush:pener.document.Form1.txtVendorName.value='"+vendorName+"';
opener.document.Form1.txtVendorNo.value='"+vendorNo+"'; 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;
.........
}
 
D

DalePres

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top