ASP.Net Jquery Find Textbox or any other control from Page (Page using Master Page)

To find any control from page which is using master page use below script
ASPX or HTML Control in ASPX Page

<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox>
<input id=”hidden1″ type=”hidden” name=”hiddenVariable” />

Jquery:

<script type=”text/javascript”>

$(document).ready(function () {

$(“input[id=TextBox1]”).val(“Jquery Text Box Value”);

$(“input[id=hiddenVariable]”).val(“Jquery Text Box Value”);
});

</script>

Advertisement

ASP.Net Set or GET JavaScript Variable Value from Code Behind

Assign Javascript Variable value which is used in Code behind

To set Javascript Variable from Code

Declate Public variable in Code which we can access from ASPX Page

ASPX Page :

For Simple Javascript VAriable

var JavaVar1 = ‘<%=strJavaVariable %>’;

or

With Control Value

<input id=”hiddenVariable” name=”hiddenVariable” value='<%=strJavaVariable %>’ />

Code Behind :

public string strJavaVariable = string.Empty;

protected void Button1_Click(object sender, EventArgs e)
{
strJavaVariable = “Button Click Event Called”;
}

SharePoint How to hide Ribbon and Quick Launch from Application Page

To hide master page , Ribbon and quick launch/left panel we need to add below css in PlaceHolderMain content

<asp:content id=”Main” contentplaceholderid=”PlaceHolderMain” runat=”server”>

<style type=”text/css”>
#s4-ribbonrow, .ms-cui-topBar2, .s4-notdlg, .s4-pr s4-ribbonrowhidetitle, .s4-notdlg noindex, #ms-cui-ribbonTopBars, #s4-titlerow, #s4-pr s4-notdlg s4-titlerowhidetitle, #s4-leftpanel-content {display:none !important;}
.s4-ca{margin-left:0px !important; margin-right:0px !important;}
</style>

</asp:content>