<% if(somecondition) { %>
some html
<% } %>
Showing posts with label asp.net. Show all posts
Showing posts with label asp.net. Show all posts
Thursday, November 12, 2015
asp.net If statement in aspx page
Thursday, September 24, 2015
asp.net create menu from datatable
public static string CrateMenuFromDT(DataTable dt)
{
string retstring = "";
DataRow[] drparentMain = dt.Select("ParentID =0 OR ParentID is null");
foreach (DataRow dr in drparentMain)
{
string strmenuselect = Convert.ToString(dr["selected"]) == "0" ? "menu_nonselected" : "menu_selected";
string strsubmenu = "";
DataRow[] drparentMenu = dt.Select("ParentID =" + Convert.ToString(dr["MenuID"]));
foreach (DataRow pdr in drparentMenu)
{
if (strsubmenu == "")
strsubmenu = " <div class='submenu_straight'><ul><li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
else
strsubmenu = strsubmenu + "<li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
}
if (strsubmenu != "")
strsubmenu = strsubmenu + "</ul></div>";
if (retstring == "")
retstring = "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
else
retstring = retstring + "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
}
return retstring;
}
{
string retstring = "";
DataRow[] drparentMain = dt.Select("ParentID =0 OR ParentID is null");
foreach (DataRow dr in drparentMain)
{
string strmenuselect = Convert.ToString(dr["selected"]) == "0" ? "menu_nonselected" : "menu_selected";
string strsubmenu = "";
DataRow[] drparentMenu = dt.Select("ParentID =" + Convert.ToString(dr["MenuID"]));
foreach (DataRow pdr in drparentMenu)
{
if (strsubmenu == "")
strsubmenu = " <div class='submenu_straight'><ul><li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
else
strsubmenu = strsubmenu + "<li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
}
if (strsubmenu != "")
strsubmenu = strsubmenu + "</ul></div>";
if (retstring == "")
retstring = "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
else
retstring = retstring + "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
}
return retstring;
}
asp.net show user zone date
public static string ShowUserZoneDate(DateTime Dbdate, double zone)
{
if (Dbdate != null)
{
TimeSpan tms = new TimeSpan(0, Convert.ToInt32(zone * 60), 0);
return Dbdate.Add(tms).ToString();
}
else
return "";
}
public static string ShowUserZoneDate(string IDbdate, double zone)
{
if (!string.IsNullOrEmpty(IDbdate))
{
DateTime Dbdate = Convert.ToDateTime(IDbdate);
TimeSpan tms = new TimeSpan(0, Convert.ToInt32(zone * 60), 0);
return Dbdate.Add(tms).ToString();
}
else
return "";
}
{
if (Dbdate != null)
{
TimeSpan tms = new TimeSpan(0, Convert.ToInt32(zone * 60), 0);
return Dbdate.Add(tms).ToString();
}
else
return "";
}
public static string ShowUserZoneDate(string IDbdate, double zone)
{
if (!string.IsNullOrEmpty(IDbdate))
{
DateTime Dbdate = Convert.ToDateTime(IDbdate);
TimeSpan tms = new TimeSpan(0, Convert.ToInt32(zone * 60), 0);
return Dbdate.Add(tms).ToString();
}
else
return "";
}
asp.net create file from base 64
public static bool CreateFileFromBase64(string fileName, string Base64Data)
{
try
{
FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
byte[] data = Convert.FromBase64String(Base64Data);
fs.Write(data, 0, data.Length);
fs.Close();
return true;
}
catch (Exception ex)
{
return false;
}
}
{
try
{
FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
byte[] data = Convert.FromBase64String(Base64Data);
fs.Write(data, 0, data.Length);
fs.Close();
return true;
}
catch (Exception ex)
{
return false;
}
}
asp.net create masked value
public static String CreateMaskedValue(string valueForMask, Int32 numberOfCharacter)
{
String maskedString = String.Empty;
int remainingCharCount = (valueForMask.Length - numberOfCharacter) < 0 ? valueForMask.Length : valueForMask.Length - numberOfCharacter;
if (remainingCharCount > 0)
{
if (!string.IsNullOrEmpty(valueForMask))
{
if (valueForMask.Length > 0)
{
maskedString = string.Concat("".PadLeft(numberOfCharacter, 'x'), valueForMask.Substring(valueForMask.Length - remainingCharCount));
}
}
return maskedString;
}
else
return valueForMask;
}
{
String maskedString = String.Empty;
int remainingCharCount = (valueForMask.Length - numberOfCharacter) < 0 ? valueForMask.Length : valueForMask.Length - numberOfCharacter;
if (remainingCharCount > 0)
{
if (!string.IsNullOrEmpty(valueForMask))
{
if (valueForMask.Length > 0)
{
maskedString = string.Concat("".PadLeft(numberOfCharacter, 'x'), valueForMask.Substring(valueForMask.Length - remainingCharCount));
}
}
return maskedString;
}
else
return valueForMask;
}
asp.net telerik convert docx to html
public static string ConvertDocxToHtml(byte[] binaryData)
{
DocxFormatProvider docxProvider = new DocxFormatProvider();
RadFlowDocument flowDoc = docxProvider.Import(binaryData);
HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
string result = htmlProvider.Export(flowDoc);
return result;
}
{
DocxFormatProvider docxProvider = new DocxFormatProvider();
RadFlowDocument flowDoc = docxProvider.Import(binaryData);
HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
string result = htmlProvider.Export(flowDoc);
return result;
}
Wednesday, September 23, 2015
Tuesday, September 22, 2015
asp.net fire button click in javascript function pass parameters
1) Javascript function
function SetDocumentEditorSrc(WrkID) {
__doPostBack('<%= btnSetRadEditorContent.UniqueID %>', WrkID);
}
2) Button Click Event
protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
String fileId = Request["__EVENTARGUMENT"]; // parameter
if (!String.IsNullOrEmpty(fileId))
{
String convertedContent = "";
RxOffice.BLL.Document document = new RxOffice.BLL.Document();
document.SetRadEditorContent(Convert.ToInt32(fileId));
if (!String.IsNullOrEmpty(convertedContent))
{
RadEditor1.Content = convertedContent;
}
}
//string filePath = Server.MapPath("~/SampleInitialContent.docx");
//byte[] fileBinaryData = File.ReadAllBytes(filePath);
//string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);
}
function SetDocumentEditorSrc(WrkID) {
__doPostBack('<%= btnSetRadEditorContent.UniqueID %>', WrkID);
}
2) Button Click Event
protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
String fileId = Request["__EVENTARGUMENT"]; // parameter
if (!String.IsNullOrEmpty(fileId))
{
String convertedContent = "";
RxOffice.BLL.Document document = new RxOffice.BLL.Document();
document.SetRadEditorContent(Convert.ToInt32(fileId));
if (!String.IsNullOrEmpty(convertedContent))
{
RadEditor1.Content = convertedContent;
}
}
//string filePath = Server.MapPath("~/SampleInitialContent.docx");
//byte[] fileBinaryData = File.ReadAllBytes(filePath);
//string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);
}
asp.net update panel
1) Update Panel
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSetRadEditorContent" EventName="Click" />
</Triggers>
<ContentTemplate>
<div style="float: left; width: 59%; margin-left: 10px; border: 1px solid #e2e6eb;">
<%--<iframe id="ifrmWrkDocViewer" src="#" style="height: 430px !important; width: 100%; margin-left: 5px;"></iframe>--%>
<telerik:RadEditor ID="RadEditor1" runat="server" ContentFilters="DefaultFilters, PdfExportFilter">
<ExportSettings FileName="RadEditorExport" OpenInNewWindow="true"></ExportSettings>
</telerik:RadEditor>
<asp:Button ID="btnSetRadEditorContent" runat="server" OnClick="btnSetRadEditorContent_Click" Style="display: none;" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
2) Button click
protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/SampleInitialContent.docx");
byte[] fileBinaryData = File.ReadAllBytes(filePath);
string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);
RadEditor1.Content = convertedContent;
}
3) Javascript Function
function SetDocumentEditorSrc(WrkID) {
__doPostBack('<%= btnSetRadEditorContent.UniqueID %>');
}
<asp:UpdatePanel runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSetRadEditorContent" EventName="Click" />
</Triggers>
<ContentTemplate>
<div style="float: left; width: 59%; margin-left: 10px; border: 1px solid #e2e6eb;">
<%--<iframe id="ifrmWrkDocViewer" src="#" style="height: 430px !important; width: 100%; margin-left: 5px;"></iframe>--%>
<telerik:RadEditor ID="RadEditor1" runat="server" ContentFilters="DefaultFilters, PdfExportFilter">
<ExportSettings FileName="RadEditorExport" OpenInNewWindow="true"></ExportSettings>
</telerik:RadEditor>
<asp:Button ID="btnSetRadEditorContent" runat="server" OnClick="btnSetRadEditorContent_Click" Style="display: none;" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
2) Button click
protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/SampleInitialContent.docx");
byte[] fileBinaryData = File.ReadAllBytes(filePath);
string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);
RadEditor1.Content = convertedContent;
}
3) Javascript Function
function SetDocumentEditorSrc(WrkID) {
__doPostBack('<%= btnSetRadEditorContent.UniqueID %>');
}
asp.net fire button click in javascript function
<asp:Button ID="btnSetRadEditorContent" runat="server" OnClick="btnSetRadEditorContent_Click" Style="display: none;" />
function SetDocumentEditorSrc(WrkID) {
__doPostBack('<%= btnSetRadEditorContent.UniqueID %>');
}
protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/SampleInitialContent.docx");
byte[] fileBinaryData = File.ReadAllBytes(filePath);
string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);
RadEditor1.Content = convertedContent;
}
function SetDocumentEditorSrc(WrkID) {
__doPostBack('<%= btnSetRadEditorContent.UniqueID %>');
}
protected void btnSetRadEditorContent_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("~/SampleInitialContent.docx");
byte[] fileBinaryData = File.ReadAllBytes(filePath);
string convertedContent = Functions.ConvertDocxToHtml(fileBinaryData);
RadEditor1.Content = convertedContent;
}
Tuesday, August 18, 2015
asp.net access c# variable in javascript
1) asp.net code behind
public partial class UploadMultipleFiles : System.Web.UI.Page
{
public string eCabinetbaseURL = Functions.ToString(ConfigurationManager.AppSettings["eCabinetServiceUrl"]);
protected void Page_Load(object sender, EventArgs e)
{
}
}
2) In Javascript function
var eCabinetServiceUrl = '<%=eCabinetbaseURL%>';
public partial class UploadMultipleFiles : System.Web.UI.Page
{
public string eCabinetbaseURL = Functions.ToString(ConfigurationManager.AppSettings["eCabinetServiceUrl"]);
protected void Page_Load(object sender, EventArgs e)
{
}
}
2) In Javascript function
var eCabinetServiceUrl = '<%=eCabinetbaseURL%>';
Jquery get session value asp.net
var sessionId = '<%=HttpContext.Current.Session["SessionID"]%>';
Tuesday, July 14, 2015
ASP.NET Jquery clear dropdown values
$('#<%=ddlStatus.ClientID%>').val("");
ASP.NET button postback from jquery
__doPostBack('<%=btnRefreshGrid.UniqueID%>', "");
Subscribe to:
Posts (Atom)