Hello everyone iam trying to open a aspx page in a dialog box window from asp button click event but even after specifying the dialog height and dialog width i want i could see dialog window opening in a default size.It seems like the height and width parameters i am passing are ignored.
Here is the Server Side Code:
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(),Guid.NewGuid().ToString(), "try { showMessageRulesDialog('MessageRuleCenterFrame.htm', true); }catch(e){alert(e);}", true);
JavaScript Code:
function showMessageRulesDialog(dialogName, refresh)
{
try {
var WinSettings = "wcenter:yes;resizable:no;onscroll:off;dialogHeight:700px;dialogWidth:610px;";
var ret = window.showModalDialog("../Dialogs/" + dialogName,"", WinSettings);
if (refresh) {
window.location = window.location;
}
}
catch (e)
{ alert("ShowDialog Error: " + e); }
}
HtmPage Properties
<iframe src="MessageRulesCenter.aspx" style="height:700px;width:610px;" frameborder="0" scrolling="yes"></iframe>
MessageRulesCenter.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="MessageRulesCenter.aspx.cs" Inherits="Dialogs_QuotaCenter" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%--<base target="_blank" /> --%>
<title>Quota Message Center</title>
<link rel="Stylesheet" href="../Skins/QuotaCenter.css" />
<script language="javascript" type="text/javascript" src="../Scripts/Common.js"></script>
<style type="text/css">
#form1
{
height: 450px;
width: 581px;
}
.formfield * {
vertical-align: middle;
border-width:0px;
}
</style>
</head>
<body style="text-align: left">
<form id="form1" runat="server">
<table style="height: 437px; width: 582px" >
<tr>
<td bgcolor="#91ACFF">
<div class="Section" id="Sec1">
<div>
<br />
<asp:Label ID="Label1" runat="server" Text="Message Rule Name : "
ForeColor="Black" Font-Bold="False"></asp:Label>
<asp:TextBox ID="txtRuleName" runat="server"></asp:TextBox>
<br /><br />
</div>
<div>
<asp:Label ID="Label2" runat="server" ForeColor="Black"
Text="Create Message Rule On :" Font-Bold="False"></asp:Label>
<br />
<br />
</div>
</div>
<div class="Section" id="Sec2">
<div>
<asp:RadioButton ID="rdoIncoming" GroupName="MessageRules" runat="server" ForeColor="Black"
Text="Incoming Message" AutoPostBack="True"
oncheckedchanged="rdoOutgoing_CheckedChanged" />
<asp:RadioButton ID="rdoOutgoing" GroupName="MessageRules" runat="server" ForeColor="Black"
Text="Outgoing Message" oncheckedchanged="rdoOutgoing_CheckedChanged"
AutoPostBack="True" />
<br />
<br />
</div>
<div>
<asp:Label ID="Label3" runat="server" ForeColor="Black" Text="Where"></asp:Label>
<br />
</div>
<div>
<p class="formfield">
<asp:Label ID="lblField1" runat="server" ForeColor="Black" Text="From field Contains :"></asp:Label>
<asp:TextBox ID="txtField3" runat="server" Width="272px" TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="btnAddContact" runat="server" Text="Add Contact" Width="102px" onclick="btnAddContact_Click"/>
<br />
</p>
</div>
<div>
<p class="formfield">
<asp:Label ID="lblFiled2" runat="server" ForeColor="Black" Text="Subject Contains :"></asp:Label>
<asp:TextBox ID="txtField4" runat="server" Width="270px"></asp:TextBox>
<br />
</p>
</div>
</div>
<div class="Section" id ="Sec3">
<div>
<asp:Label ID="Label4" runat="server" ForeColor="Black" Text="Then"></asp:Label>
</div>
<div>
<p class="formfield">
<asp:RadioButton ID="rdoMove" runat="server" GroupName ="ActionType" ForeColor="Black" Text="Move it to the Folder : " />
<asp:DropDownList ID="ddlMove" runat="server" Width="165px" onselectedindexchanged="ddlMove_SelectedIndexChanged" >
</asp:DropDownList>
</p>
</div>
<div>
<p class="formfield">
<asp:RadioButton ID="rdoCopy" runat="server" GroupName ="ActionType" ForeColor="Black" Text="Copy it to the Folder : " />
<asp:DropDownList ID="ddlCopy" runat="server" Width="165px" onselectedindexchanged="ddlMove_SelectedIndexChanged" >
</asp:DropDownList>
</p>
</div>
<div style="text-align:right">
<asp:Label ID="lblError" runat="server"></asp:Label>
<p class="formfield">
<asp:Button ID="btnDone" runat="server" Text="Done" OnClick="btnDone_Click" Width="61px" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Cancel" />
</p>
</div>
</div>
</td>
</tr>
</table>
</form>
I tried your code and it seems it works fine. My guess for why it is not working as expected could be because of the browser version.
Check if you get the required behavior if you remove the Doctype declaration (the top most line in the page).
Related
<form id="form1" runat="server">
<div id="header" runat="server" class="clsHeaderContent">
<div class="clsDivBody">
<table cellpadding="0" border="0" cellspacing="0" style="width: 1024px;">
<tr>
<td>
<a href="<%=Page.ResolveUrl("~/Main/Home.aspx")%>">
<asp:Image ID="imgLogo" runat="server" ImageUrl="~/Images/Logo.png" Style="border: 0" />
</a>
</td>
</tr>
<%
If Not Session("Member_Login_Profile") Is Nothing Then
%>
<tr style="height:30px;">
<td align="right" valign="top">
<asp:Button ID="cmdHome" runat="server" Text="Home" />
<asp:Button ID="cmdMyProfile" runat="server" Text="My Profile" />
<asp:Button ID="cmdLogout" runat="server" Text="Logout" />
</td>
</tr>
<tr style="height: 5px;">
<td/>
</tr>
<%
End If
%>
</table>
</div>
</div>
<div class="clsDivBody bg" style="padding: 15px 0;min-height:730px;">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
<div id="backtotop" style="display: block;">^ Back to Top</div>
<div id="push"></div>
<input type="hidden" id="_ispostback" value="<%=Page.IsPostBack.ToString()%>" />
</form>
<form >
<asp:TextBox ID="txtCardNo" runat="server" MaxLength="20" value="Card No." Text="824488" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Card No.':this.value;" />
<asp:RequiredFieldValidator ID="reqCardNo" runat="server" ControlToValidate="txtCardNo" CssClass="clsValidationErrMsg" Display="dynamic" ValidationGroup="Login" />
<asp:RegularExpressionValidator ID="regExCardNo" runat="server" ControlToValidate="txtCardNo" CssClass="clsValidationErrMsg" Display="dynamic" ValidationGroup="Login" />
<asp:TextBox ID="txtPassword" runat="server" MaxLength="16" value="thegardensclub123" TextMode="Password" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Password':this.value;" />
<asp:RequiredFieldValidator ID="reqPassword" runat="server" ControlToValidate="txtPassword" CssClass="clsValidationErrMsg" Display="dynamic" ValidationGroup="Login" />
<asp:RegularExpressionValidator ID="regExPassword" runat="server" ControlToValidate="txtPassword" CssClass="clsValidationErrMsg" Display="dynamic" ValidationGroup="Login" /><br/>
<%-- <u><asp:LinkButton ID="lnkForgotPwd" runat="server" CausesValidation="False" Text="Forgot your password?" /></u>
--%> <asp:Button runat="server" ID="btnLogin" Text="Log In"/>
</form>
The first snippet is my master page, and the second is my login page.
The problem is, if i dont remove the in master page my textbox in login page, the textbox can not be placed in the panel.
If i remove the in master page, its shows me this error "Control 'ctl00_MainContent_oSM' of type 'ScriptManager' must be placed inside a form tag with runat=server."
If i remove the in login, also the textbox can not be placed in the panel. So what should i do?
I have panel in my HTML like this:
<asp:Panel ID="cropPanel" runat="server">
<div class="col-xs-6">
<h3 style="text-align:center; text-decoration:solid;">Before image: </h3>
<img style="width:100%;" id="before" src="" runat="server" />
<asp:HiddenField ID="X1" runat="server" />
<asp:HiddenField ID="Y1" runat="server" />
<asp:HiddenField ID="W1" runat="server" />
<asp:HiddenField ID="H1" runat="server" />
</div>
<!-- After image -->
<div class="col-xs-6">
<h3 style="text-align:center; text-decoration:solid;">After image: </h3>
<img style="width:100%;" id="after" src="" runat="server" />
<asp:HiddenField ID="X2" runat="server" />
<asp:HiddenField ID="Y2" runat="server" />
<asp:HiddenField ID="W2" runat="server" />
<asp:HiddenField ID="H2" runat="server" />
</div>
</asp:Panel>
This is the logic for getting the cropped image new dimensions using jQuery/JavaScript like following:
$('#<%=before.ClientID%>').Jcrop({
onSelect: SelectCropArea
});
function SelectCropArea(c) {
$('#<%=X1.ClientID%>').val(parseInt(c.x1));
$('#<%=Y1.ClientID%>').val(parseInt(c.y1));
$('#<%=W1.ClientID%>').val(parseInt(c.w1));
$('#<%=H1.ClientID%>').val(parseInt(c.h1));
}
$('#<%=after.ClientID%>').Jcrop({
onSelect: SelectCropArea2
});
function SelectCropArea2(c) {
$('#<%=X2.ClientID%>').val(parseInt(c.x2));
$('#<%=Y2.ClientID%>').val(parseInt(c.y2));
$('#<%=W2.ClientID%>').val(parseInt(c.w2));
$('#<%=H2.ClientID%>').val(parseInt(c.h2));
}
And when I press the link button event:
<asp:LinkButton ID="linkCrop" OnClick="linkCrop_Click" runat="server">Save & Upload</asp:LinkButton>
Code behind:
Rectangle CropAreaBefore = new Rectangle(Int32.Parse(X1.Value), Int32.Parse(Y1.Value), Int32.Parse(W1.Value), Int32.Parse(H1.Value));
Rectangle CropAreaAfter = new Rectangle(Int32.Parse(X2.Value), Int32.Parse(Y2.Value), Int32.Parse(W2.Value), Int32.Parse(H2.Value));
//The `X1/Y1/W1/H1 and X2/Y2/W2/H2 are empty
What am I doing wrong here??
Edit: I checked whether the values are set properly in jquery, they are, here's the pic showing it:
Can someone help me?
My js is not working, I hide the divId and when I click te button the divId should appear but nothing happens! I am sending the code below.
What am I doing wrong, could it be in the master page file?
%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AppTest.aspx.cs" Inherits="AppTest.Screens.UploadFile" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<style>
.hidden{
display: none;
}
</style>
<div class="row">
<h2>File Upload</h2>
<br />
<asp:Panel ID="panelUpload" runat="server">
<p> <asp:Label ID="lblFileUpload" Width="300px" runat="server">Select the file:</asp:Label>
<asp:FileUpload ID="fileUP" runat="server" /></p>
<p>
<asp:Label ID="lblDdl" runat="server">Paciente</asp:Label>
<asp:DropDownList ID="ddl1" runat="server">
</asp:DropDownList>
</p>
<br />
</asp:Panel>
<div id="divId" class="hidden">
</br>
<h2>Cadastro de paciente</h2>
<br />
<p>
<asp:Label ID="lblName" runat="server">Name:</asp:Label>
<asp:TextBox ID="txtName" runat="server" Width="140px"></asp:TextBox>
</p>
<p>
<asp:Label ID="lblLast" runat="server">Last Name:</asp:Label>
<asp:TextBox ID="txtLastName" runat="server" Width="140px"></asp:TextBox>
</p>
<p>
<asp:Label ID="lblAge" runat="server">Age:</asp:Label>
<asp:TextBox ID="txtAge" runat="server" Width="140px"></asp:TextBox>
</p>
<br />
</div>
<p>
<div class="col-md-6">
<asp:Button ID="btnInsert" runat="server" Text="Inserir"/>
</div>
<div class="col-md-6">
<button>New</button>
</div>
</p>
</div>
</asp:Content>
<asp:Content ContentPlaceHolderID="ScriptPlaceHolder1" ID="scripts" runat="server">
<script src="../Scripts/jquery-1.10.2.js" ></script>
<script>
$(document).ready(function () {
$('button').on('click', function () {
$('#divId').show(); // aparece o div
});
});
</script>
</asp:Content>
So When you do Button click your page is loaded again because postback occurs. in your aspx page you have defined your class as hidden in aspx page. So you can prevent this by this way.
$('button').on('click', function () {
$('#divId').show(); // aparece o div
return false;
});
There are multiple way of doing this, I have shown you one way.
Below is my Html Code:
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" CodeBehind="BranchRegistration.aspx.cs" Inherits="BloodBank.BranchRegistration" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="settings_pagecontent">
<div class="addform">
<asp:Button ID="BtnAdd" runat="server" CssClass="button" Text="Add" />
<br />
<br />
</div>
<div class="form">
<div class="settings_border-line">
<div class="settings_label_left">
<asp:Label ID="lblbranchname" class="settings_label_inv" runat="server" Text="Branch Name"></asp:Label>
<br />
<br />
<asp:Label ID="lblbranchphonenumber" class="settings_label_inv" runat="server" Text="Phone Number"></asp:Label>
<br />
<br />
</div>
<div class="text_right">
<asp:TextBox ID="txtbranchname" class="settings_textbox_body Branch_txt" runat="server"></asp:TextBox><br />
<br />
<asp:TextBox ID="txtbranchphonenumber" class="settings_textbox_body" runat="server"></asp:TextBox>
<asp:Label ID="lblbranchemailid" class="settings_label_inv" runat="server" Text="Email ID"></asp:Label>
<asp:TextBox ID="txtbranchemailid" class="settings_textbox_body" runat="server"></asp:TextBox>
</div>
<div class="clear"></div>
</div>
<br />
<br />
<div class="border-line">
<div class="label_left" style="width: 150px">
<asp:Label ID="lblbranchaddress" class="settings_label_inv" runat="server" Text="Branch Address"></asp:Label>
<br />
<br />
<asp:Label ID="lblbranchlandmark" class="settings_label_inv" runat="server" Text="Landmark"></asp:Label>
<br />
<br />
<asp:Label ID="lblTehsil" class="settings_label_inv" runat="server" Text="Tehsil"></asp:Label>
<br />
<br />
<asp:Label ID="lblbranchstate" class="settings_label_inv" runat="server" Text="State"></asp:Label>
<br />
<br />
<asp:Label ID="lbllocationmap" class="settings_label_inv" runat="server" Text="Location"></asp:Label>
<br />
<br />
</div>
<div class="text_right" style="width: 670px">
<asp:TextBox ID="txtbranchaddress" class="settings_textbox_body" runat="server"></asp:TextBox>
<asp:Label ID="lblbranchstreet" class="settings_label_inv" runat="server" Text="Street"></asp:Label>
<asp:TextBox ID="txtbranchstreet" class="settings_textbox_body" runat="server"></asp:TextBox>
<br />
<br />
<asp:TextBox ID="txtbranchlandmark" class="settings_textbox_body" runat="server"></asp:TextBox>
<asp:Label ID="lblbranchlocality" class="settings_label_inv" runat="server" Text="Locality"></asp:Label>
<asp:TextBox ID="txtbranchlocality" class="settings_textbox_body" runat="server"></asp:TextBox>
<br />
<br />
<asp:TextBox ID="txttehsil" runat="server" class="settings_textbox_body"></asp:TextBox>
<asp:Label ID="lblDistrict" class="settings_label_inv" runat="server" Text="District"></asp:Label>
<asp:TextBox ID="txtDistrict" runat="server" class="settings_textbox_body"></asp:TextBox>
<br />
<br />
<asp:DropDownList ID="ddlState" runat="server" class="settings_textbox_body"></asp:DropDownList>
<asp:Label ID="lblbranchpincode" class="settings_label_inv" runat="server" Text="Pincode"></asp:Label>
<asp:TextBox ID="txtbranchpincode" class="settings_textbox_body" runat="server"></asp:TextBox>
<br />
<br />
<asp:TextBox ID="txtbranchlocationmap" class="settings_locationmap" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="invSubmit" runat="server" Text="Submit" />
<asp:Button ID="invReset" runat="server" Text="Reset" />
</div>
<div class="clear"></div>
</div>
</div>
<div class="grid">
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('<%=txttehsil.ClientID%>').autocomplete({
source: function (request, response) {
$.ajax(
{
type: "POST",
contentType: "application/json; charset=utf-8",
url: "BranchRegistration.aspx/GetNames",
data: "{'name':'" + $('<%=txttehsil.ClientID%>').val() + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (err) {
alert("Error: " + err);
}
});
}, minLength: 1
});
});
</script>
<link href="Content/site1.css" rel="stylesheet" />
<link href="Content/Site.css" rel="stylesheet" />
</asp:Content>
And server side code is as follow:
[System.Web.Services.WebMethod]
public static List<string> GetNames(string name)
{
List<string> nameList = new List<string>();
string strSqlQuery = "Select * from SubRegions where SubRegionName like '%" + name + "%'";
SqlDataAdapter da = new SqlDataAdapter(strSqlQuery, Common.GetConnectionString());
DataSet ds = new DataSet(); da.Fill(ds, "SubRegions");
DataTable dt = ds.Tables["SubRegions"];
DataRowCollection drc = dt.Rows;
foreach (DataRow dr in drc)
{
nameList.Add(dr["SubRegionName"].ToString());
}
return nameList;
}
This code is run without a master page, but it is not run in my application. Please give me proper answer. In this page autocomplete textbox is use.It is jquery ajax application. I use this code in another project its execute properly and gave me proper result.
Add "System.Web.Script.Services.ScriptMethodAttribute()" in your server code, the problem is solved.
your sever code look like this
[System.Web.Services.WebMethod ,System.Web.Script.Services.ScriptMethodAttribute()]
public static List<string> GetNames(string name)
{
List<string> nameList = new List<string>();
string strSqlQuery = "Select * from SubRegions where SubRegionName like '%" + name + "%'";
SqlDataAdapter da = new SqlDataAdapter(strSqlQuery, Common.GetConnectionString());
DataSet ds = new DataSet(); da.Fill(ds, "SubRegions");
DataTable dt = ds.Tables["SubRegions"];
DataRowCollection drc = dt.Rows;
foreach (DataRow dr in drc)
{
nameList.Add(dr["SubRegionName"].ToString());
}
return nameList;
}
Using teleriks drag and drop demo I'm able to reproduce the functionality, however, what I want to do is if the browser isn't HTML5 compliant I want to load a different function. Below is the code i'm using.
<script type="text/javascript">
var $ = $telerik.$;
function pageLoad() {
if (!Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable()) {
$(".wrapper").replaceWith(
$("<span><strong>Your browser does not support Drag and Drop. Please take a look at the info box for additional information.</strong></span>"));
}
}
function added(sender, args) {
if (Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable()) {
$(".ruDropZone").html("<div align=\"center\"><img src=\"images/logo.png\" width = \"300\"></div>");
}
}
</script>
I realize that you want to replace this section with the code you want:
if (!Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable()) {
$(".wrapper").replaceWith(
How do I include whats below in this in the .replaceWith(
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" OnClientAdded="added" OnFileUploaded="RadAsyncUpload1_FileUploaded">
</telerik:RadAsyncUpload>
<br />
<telerik:RadProgressManager ID="Radprogressmanager1" runat="server" />
<div style="position:relative;">
<table>
<tr>
<td id="controlContainer">
<telerik:RadUpload
ID="RadUpload1" runat="server"
MaxFileInputsCount="5"
OverwriteExistingFiles="false" />
<telerik:RadProgressArea id="progressArea1" runat="server"/>
<asp:Button id="buttonSubmit" runat="server" CssClass="RadUploadSubmit" OnClick="buttonSubmit_Click" text="Submit" />
</td>
<td>
<div class="smallModule">
<div class="rc1"><div class="rc2"><div class="rc3" style="width:240px">
<asp:Label ID="labelNoResults" runat="server" Visible="True">No uploaded files yet</asp:Label>
<asp:Repeater ID="repeaterResults" runat="server" Visible="False">
<HeaderTemplate>
<div class="title">Uploaded files in the target folder:</div>
</HeaderTemplate>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>
<br />
</ItemTemplate>
</asp:Repeater>
</div></div></div></div>
</td>
</tr>
</table>
</div>
</div>
This is how I did it, by creating additional divs and hiding elements based on divs
<script type="text/javascript">
var $ = $telerik.$;
function pageLoad() {
if (!Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable()) {
$(".wrapper").replaceWith(
$(""));
}
}
function added(sender, args) {
if (Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable()) {
$(".ruDropZone").html("<div align=\"center\"><img src=\"images/logo.png\" width = \"300\"></div>");
$(".nonHTML5").replaceWith(
$(""));
}
}
</script>
<div class="wrapper">
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" OnClientAdded="added" OnFileUploaded="RadAsyncUpload1_FileUploaded">
</telerik:RadAsyncUpload>
<br />
<telerik:RadProgressManager ID="Radprogressmanager1" runat="server" />
</div>
<div class ="nonHTML5" style="position:relative;">
<table>
<tr>
<td id="controlContainer">
<telerik:RadUpload
ID="RadUpload1" runat="server"
MaxFileInputsCount="5"
OverwriteExistingFiles="false" />
<telerik:RadProgressArea id="progressArea1" runat="server"/>
</td>
<td>
<div class="smallModule">
<div class="rc1"><div class="rc2"><div class="rc3" style="width:240px">
<asp:Label ID="labelNoResults" runat="server" Visible="True">No uploaded files yet</asp:Label>
<asp:Repeater ID="repeaterResults" runat="server" Visible="False">
<HeaderTemplate>
<div class="title">Uploaded files in the target folder:</div>
</HeaderTemplate>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>
<br />
</ItemTemplate>
</asp:Repeater>
</div></div></div></div>
</td>
</tr>
</table>
</div>
<asp:Button id="buttonSubmit" runat="server" CssClass="RadUploadSubmit" OnClick="buttonSubmit_Click" text="Submit" />
</td>
</tr>