User Control(textbox id,text+Tree)

Posted on 23/03/2011. Filed under: Asp.net 2.0 |

Code Behind for Ctl

public
partial class controls_textBoxWithTreeCtl : System.Web.UI.

 

{

 
public string CacheName{ get { return varCacheName; } 

 

 

 

set { varCacheName = value; }
 

 

 
}
 
 

 

 

 

private string varTreeDBClassId;

 public string TreeDBClassId{

get { return varTreeDBClassId; } 

 

 
 set { varTreeDBClassId = value
 
}

; }

 
 

 

 

 

private string varTreeFladId; 

 

 

public string TreeFladId{

 
get { return varTreeFladId; }   set { varTreeFladId = value; }}

 

 private string varCtlId; 

 

 public string CtlId{

 

 
set { varCtlId = value; }} 

 

 protected void Page_Load(object sender, EventArgs

e){
 
 

 

“onclick”, “javascript:OpenTrees(“ + “‘” + varTreeFladId + “‘ ,’” + varTreeDBClassId + “‘ , ‘” + varCtlId + “‘” + “);”

); 
}

 

 

 
 

 

protected void TxtCode_TextChanged(object sender, EventArgs

e){
 
 

 

if ((Hashtable)HttpRuntime.Cache[varCacheName] == null

){
 

 

Utility

.CheckCashAvailable(); } 
 

 

if (((Hashtable)HttpRuntime.Cache[varCacheName])[TxtCode.Text.Trim()] != null

){
 
 

 

Hashtable)HttpRuntime

.Cache[varCacheName])[TxtCode.Text.Trim()].ToString();txtText.ToolTip = ((
 

 

Hashtable)HttpRuntime

.Cache[varCacheName])[TxtCode.Text.Trim()].ToString();}
 
 

 

else
 

 

{
 
 

 

“”

 

;}
}

 

 
 

 

protected void txtText_TextChanged(object sender, EventArgs

e){
}

 

}

 private string varCacheName;
 

 

 

txtText.Text =

 

 

 

txtText.Text = ((

 

 

 

imgInternalSite.Attributes.Add(

 

 

get { return varCtlId; } 

Add the following Code On the popup Window Trees.aspx

 

 

 

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs 

{

ReadParameters();

e)

 

ClientScriptManager

 

 

script = Page.ClientScript;

 

if (script.IsStartupScriptRegistered(this.GetType(), “Alert”) == false

{

{ script.RegisterStartupScript(

)

 

this.GetType(), “Alert”, “readSelectedValue(‘” + TreeView1.SelectedNode.Text + “‘ ,’” + TreeView1.SelectedNode.Value + “‘,’” + CtlId + “‘);”, true

}

}

); }

 

 

Add the following Javascript Function in the Trees.aspxx Page



 

 

 

<script language=”javascript” type

=”text/javascript”>

 

 

 

 

function

readSelectedValue(NodeText,NodeValue,CtlId) { 

opener.FillRelatedControls(NodeText, NodeValue, CtlId);

window.close();

}

 

 

 

</script>

 Add the Following Javascript Funtion to the common.js File

 

function

 

 

OpenTrees(val, ClassID, ctlId) { 

 

 

//alert(ctlId);

 

 

 

 

//val Define the cri example internal sites external

 

 

window.open(

 

“../Trees.aspx?flag=” + val + “&ClassID=” + ClassID + “&CtlId=” + ctlId, “_blank”, ‘width=450,height=550,toolbar=0,resizable=0,scrollbars=no’

);event.returnValue =

 

 

false

;}

 

 

function

 

 

FillRelatedControls(NodeText, NodeValue,CtlId) { 

 

 

var varTxtCode = CtlId + “_” + “TxtCode”

; 

 

 

var varTxtText = CtlId + “_” + “TxtText”

; 

 

 

var varHiddenCode = CtlId + “_” + “hiddenCode”

; 

 

 

var varHiddenText= CtlId + “_” + “hiddenText”

; 

 

 

var

objTxtCode = document.getElementById(varTxtCode); 

 

 

var

objTxtText = document.getElementById(varTxtText); 

 

 

var

objHiddenCode = document.getElementById(varHiddenCode); 

 

 

var

objHiddenText = document.getElementById(varHiddenText); 

 

 

//alert(‘objTxtText=’ + objTxtText);

 

 

objTxtCode.value = NodeValue;

objTxtText.value = NodeText;

objHiddenCode.value = NodeValue;

objHiddenText.value = NodeText;

}

>

 

 

 
UserControl
 

 

Advertisement

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.