C# -get Rid Of Repetitive Code?
Nov 12, 2010
<telerik:RadEditor ID="Editor1" runat="server">
<CssFiles>
<telerik:EditorCssFile value="../Skins/CustomSkin/Editor.CustomSkin.css"/>
<telerik:EditorCssFile value="../Skins/CustomSkin/Editor.CustomSkin.css"/>
<telerik:EditorCssFile value="../Skins/CustomSkin/Editor.CustomSkin.css"/>
[code]...
How do I get rid of this repetitive code? I need to define "CSsFiles" somewhere in my code only once and not thrice like above, then use that function or whatever for ALL the Editor controls on my page.
View 2 Replies
Similar Messages:
Aug 9, 2010
I have a table for labels in SQL server, in this table i hold all the text for all the labels i use in my website. The reason i am doing this is because i creating a bilingual site, which will display two languages on one page at the same time. The other language being arabic.
So what this means is that whenever a page loads, it needs to go and fetch the text of the labels from the database to display them on the page.
the way i have done this is that i have created a class called labels, and in this class i have created two methods, one called GetEnglishLabel(ID) and the Other Called GetArabicLabel(ID). Both methods take an ID, which corresponds to the id in the sql server database. Each of these functions is using LinqToSql to get the text for the label for the given ID.
My problem is that for every label i need to call this function, so as you might imagine on one page i might have over a hundred calls to these functions on page_load.
View 2 Replies
Jan 22, 2011
In my website, I need to do a repetitive task which should not affect the main activity and performance of the website.
So I think I need to use threading. I am new into threading in .Net.
How to use threading is .NET?
View 1 Replies
Mar 30, 2010
What is the best method in T-SQL 2008 for extending a table's records with the criteria of 'repeating' all fields but the Primary KEY e.g. Consecutive Date for the previous n Records.
So you have for example 7 records (Easy...2 Fields. Date and nvarchar) with th Date runing from Jan-01 to Jan-07
We want to extend the table by 21 records...so
Record 1,8,15,22 will look identical apart from the DateField.
Record 2,9,16,23 will look identical apart from the DateField. etc...etc..
I have tried a number of methods ...all coming up short....
View 4 Replies
Apr 12, 2010
Following is the code to insert userName from session and PageName into table to keep record that how many times a user does hit a particular page.
To avoid repitition of code I want to put the code in one class and want to inherit same code in each page.
How to get this task? Please do share with me? Here is the OK code:
[Code]....
View 17 Replies
Jul 30, 2010
I've the Javascript code to do a confirmation before deletion of some records
function confirmDelete()
{
if(confirm('Delete all?'))
{
return true;
}
else
{
return false;
}
}
I've the button code here
<asp:Button ID="btnDelete" runat="server" onClientClick="return confirmDelete();" onClick="btnDelete_click" />
If i've the button outside an update panel (basically i'm using RadAjaxPanel by Telerik) it is working fine. But when the button is inside an ajax panel, even if i click OK for deleting the records the server side code is not called.
View 2 Replies
May 1, 2010
I'm missing a the code browser when I create pages that have the code not placed in a seperate file. For pages with .asp.vb files I get the browser correctly.
I think it's called a code browser but just in case it's not I mean the dropdown that shows Page Events, Buttons and other controls that can be selected along with their events.
How do I turn on those dropdowns for pages with code behind that uses <script> tags in the actual .aspx page?
Included (Showing page events just under the tab):
Missing
View 1 Replies
Mar 3, 2010
I want to call a function present in code behind from front page (html : source code)
i want to use like this:
Source code
<a href='<%# linkAlpha("B").ToString()) %>' title="B" id="B_List" runat = "server">B</a>
Code Behind
protected string linkAlpha(string value)
{
// /market-research/<%#Eval("customname")%>/
string str = "";
if (Request.Url.DnsSafeHost == "localhost")
{ // /market-reports/<%# Eval("customname")%>/
str = "Alpha_Category.aspx?q=" + value.ToString().Trim();
// Response.Redirect("Alpha_Category.aspx?q=" + value.ToString().Trim());
}
else
{
// str = "/market-reports/" + value.ToString().Trim() + "/";
str = "/Alpha_Category.aspx?q=" + value.ToString().Trim();
}
return str;
}
View 2 Replies
May 18, 2010
how do you call code behind button click event or a code behind method
from javascript.
View 8 Replies
Apr 16, 2010
Can the select command of a SqlDataSource be given by code in the code behind file. Also by calling the SqlDataSource.Select can the select statement be executed?
View 3 Replies
May 25, 2010
I have an asp.net button, that when clicked calls a code behind function. The function does some evaluation, and then I want to call javascript from within this asp.net function.
View 2 Replies
Dec 3, 2010
I want to bind an ObjectDataSource to a property in my asp page and I want to do it in the page's aspx code, not in code-behind. I've already done it in code-behind, as follows:
[Code]....
I'd prefer to get rid of the ugly code-behind and just do this in mark-up. Something like
[Code]....
This gives me a run-time error: Cannot create an object of type 'System.Object' from its string representation 'SelectedBook' for the 'DataSource' property.Is there a way of doing this declaratively and not in code-behind? Further, what if what I want is to actually use a child property of the property in question? For example, if my Book object has a ReaderComments collection, can I databind to it decaratively in the aspx mark-up?
View 1 Replies
Nov 12, 2010
anyone use/ know of any library or website with code snippets or samples with many of the mundane boilerplate code and/ or functions like data access, data scrubbing, recursive routines...
preferably c# since most of .net in the real world is c#. VB is ok too.
View 2 Replies
Jul 1, 2010
I have a number of radio buttons on my page. When one is selected, I wish for certain controls to be made visible/invisible.
Can anyone tell me the property to code in VB behind code?
View 5 Replies
Dec 30, 2010
how to generate HTML code from the code behind?
I would like to build a form that generate an html code inside a for loop.
I will let the user enter the photo name and No. of photos
Then I will generate an HTML code like this:
<a href="http://www.mzinj.org/images/gallery/Photo%20(1).jpg" target="_blank"> <img src="http://www.mzinj.org/images/gallery/Photo%20(1).jpg" alt="" width="345" height="247" /> </a> <br /> <a href="http://www.mzinj.org/images/gallery/Photo%20(2).jpg" target="_blank">
<img src="http://www.mzinj.org/images/gallery/Photo%20(2).jpg" alt="" width="345" height="247" /> </a> <br /> <a href="http://www.mzinj.org/images/gallery/Photo%20(3).jpg" target="_blank"> <img src="http://www.mzinj.org/images/gallery/Photo%20(3).jpg" alt=""
width="345" height="247" /> </a> <br />
depending on the No. of the photos the code will be duplicated in the loop
Then I will display the result of the loop in label or in a textarea to let the user copy it any where
The problem is that while compiling my code it considers the HTML code as a part of the behind file and gives errors on the single quote, the double quote and on the parentheses
View 4 Replies
Feb 28, 2010
I have a page with a Textbox, a Button and a Label control. On Button_Click event , I store the value of Textbox in a variable called S using code behind.
I want to show the value of S in the Lable control using inline code but not using the code behind. ?
View 2 Replies
Jan 9, 2010
all of a sudden i cant copy or paste code snippets in my code. what can it be? neither i can copy the folder from the wwwroot folder.
View 1 Replies
Nov 24, 2010
After insert a grid or any other tool into an aspx page it generates enough code for that tool(for ex.): <dx:ASPxGridView ID=ASPxGridView1 runat="server"></dx:ASPxGridView>...
But,after adding any property to this control (like Show group Panel) it generates more than 3000 lines of code in aspx page () and after adding any other tool the code is increasing in a enormous way...
How can I reduce the code, maybe there is a property(settings) in DevExpress option...
View 2 Replies
May 3, 2010
I have an ASMX Web Service that has its code entirely in a code-behind file, so that the entire contents of the .asmx file is:
<%@ WebService Language="C#" CodeBehind="~/App_Code/AddressValidation.cs" Class="AddressValidation" %>
On my test machine (Windows XP with IIS 5), I set up a virtual directory just for this ASP.NET 2.0 solution and everything works great. All my code is separated nicely and it just works.However, when we deployed this solution to our Windows Server 2003 development environment, we noticed that the code only compiled when all of the code was dropped directly into the .asmx file, meaning that the solution didn't work with code-behind. We can't figure out why this is happening.
One thing that's different about our setup in our development environment is that instead of creating a separate virual directory just for this solution, we dropped it into an existing directory that runs a classic ASP application. So here we have a folder with an ASP.NET 2.0 application within a directory that contains a classic ASP application. Granted, everything in the ASP.NET 2.0 application works if all of the code is within the .asmx file and not in code-behind, but we'd really like to know why it's not recognizing the code-behind files and compiling it correctly.
View 3 Replies
Aug 2, 2010
I have a web app that needs to do two things at the same time. After a user clicks a button on the site, a javascript function needs to execute and while thats working I need the server side code for the button click to execute without waiting on the client side to finish.
To be more specific, the client side function takes about 23 seconds to complete, and while that is running the server side code promts the user for printing a document. So I need the javascript to run "in the background".
View 3 Replies
Jun 22, 2010
I have a WCF 3.5 service with JSON and a aspx page consuming it by using ASP.NET Ajax Library
I was able to call service succesfully.In the aspx page I wrote my Java code directly and then I wanted to modify my JS function but it is always picking the old JS function code
I even restarted the machine no change, looked up on the internet, msdn and I have Default pool with Integration mode
code bellow
<asp:ScriptManager
ID="ScriptManager1"
runat="server" [code]....
View 2 Replies
Mar 14, 2011
I'm using CRv9 and want to make use of Google Charts API for generating QR code on fly (in asp .net) and display it in the Crystal Report in a PDF format.I have spent the whole day looking for solution with no luck. The way we output the report is we use .rpt file, feed it with data and use Response.OutputStream to feed to browser. No CrystalReportViewer control hence CSS solution is not an option.
Now, I got as far as added an OLE Object from file with Link, which I would be overwriting every time the new QR code is generated. I apreciate that CR requires it to be a bitmap, so I was planning to download and convert the google's generated PNG file to BMP, that's not an issue. The problem is that Image in the report does not update after I replace the file. Meaning, it displays the original image, which was added as an OLE Object.
If I open this report in CR designer, the image gets refresh/updated and I'd have to save changes to the report to see this new image next time I generate a PDF file.The question is really how to achieve a dynamic image in Crystal Reports 9? Remember, Picture object did not have a Graphic Location property until vXI, so I cannot use that.
Manipulations with DataSets is not an option either as we're not giving report a datasource, instead we just map the fields with FormulaFieldDefinitions.
sample qr code url: https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=Hello%20world&choe=UTF-8
View 3 Replies
Mar 25, 2011
I have been asked to support a legacy app and I can't get access to the code behind files. I need to add a new feature that gets a list of items from the database on page_load, what way would adding an "in-page" page_load affect the compiled page_load?
View 2 Replies
Feb 28, 2010
How to Use a Variable Defined in Code Behind File on inline code for same page..
View 7 Replies
Jan 27, 2010
Is it safe to hard code username and password on backend code?
View 3 Replies