.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Server.MapPath in javascript on user control

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net
 

I am trying to open this page through javascript, but I want it to work at any page level since it is on a user control that is the footer for all my pages.  Let me knwo if there is a better way and or what is wrong with the javascript function below.


function openNewWindows()
    { window.open(<%= Server.MapPath("~/MyContacts.aspx"); %>)}




View Complete Post


More Related Resource Links

embedded javascript in user control

  
Hello, I would like to know if it is possible to embed javascript in a user control. I've followed this article advices. It works with a custom server control but not with a web user control. Is there something special to do to make it work with user controls ?Moreover, it would be nice that only one javascript reference (<script src=""></script>) figure on the page if I use the same user control several times on the page. Is it possible ? Thanks, mathmax 

problem with user control+update panel+javascript

  

hai all,

 

Im having a aspx page which has 5 tabs inside a update panel..also I have a user control

Wen I click each tab im dynamically loading dat user control .

The problem is im using javascript in dat user control..

the user control has a button which displays a panel containing three grid views  n s activated by a java script as given below..

function Elig()

{

$(document.getElementById(

'<%=btnLegend.ClientID %>')).click(function(){

$(document.getElementById(

('<%=pBody.ClientID %>')).slideToggle('slow');

 

});

}

Wen i run the aspx page the first tab  successfully loaded with dat user control n a

Acessing controls in usercontrol in javascript function where user control hosted in webpart

  

Hi,

1how to acess controls in usercontrol  in javascript function where user control hosted in webpart

or

2)How to retieve values from javscript code to server side

details as follows

StringBuilder controlString = new StringBuilder();
           
           
            controlString.Append("<p>" + CurrentPage.ToString() + "of " + TotalPages.ToString() + " </p>");
            controlString.Append("</div>");
        
            controlString.Append("<ul>");
            for (int intIndex = 1; intIndex <= TotalPages; intIndex++)
            {
              
                controlString.Append("<li><a hre

Not able to access child controls in user control using javascript

  

Hi

I have a user control "SettingsControl" containing an ajax:CollapsiblePanelExtender which in turn has a GridView (gridView) and checkBoxes. On top of GridView we have two LinkButtons "Select All" and "Clear All". I have written to enable select all and clear all functionality. Select All should select all the rows in the grid by calling the following JavaScript written on the Client .aspx file.

function SelectAll(chk)
{    
    //get reference of GridView control
    var grid = document.getElementById('<%= SettingsControl1.FindControl("gridView").ClientID %>');
    //variable to contain the cell of the grid
    var cell;

    if (grid.rows.length > 0)
    {
        //loop starts from 1. rows[0] points to the header.
        for (i=1; i<grid.rows.length; i++)
        {
            //get the reference of first column
            cell = grid.rows[i].cells[0];

         &nbs

Embedded Javascript File in Custom Server Control

  


Hi,

I am creating a custom server control, and I am wanting to include a JavaScript file in the dll file when the control is built. I have tried suggestions from the following websites:


http://weblogs.asp.net/dwahlin/archive/2007/04/29/creating-custom-asp-net-server-controls-with-embedded-javascript.aspx

http://www.infinitezest.com/articles/embedding-javascript-files-in-your-custom-controls.aspx

http://www.4guysfromrolla.com/articles/080906-1.aspx


But after following the directions, If I use firebug to see what errors show up, the JavaScript functions that are being called all say "goNext is not defined" which leads me to believe the JavaScript file is not being added correctly. 

Some information on what my control looks like

I have the JavaScript File in a folder called Script. The namespace of the project is CustomControl, and the Name of the project is MaskedDateTextbox.

In my AssemblyInfo I have the following:


Call javascript function on containing page from user control

  

I have a toolbar in a user control.  I would like to wire the toolbar's onclick event to a javascript function on the page that contains the user control.  What's the easiest way to do this?


Set value of TextBox in User Control from Javascript

  

Hi,

I have a page with a user control. I'm trying to populate the values of the textboxes in the User control from javascript in the main page.

 

Screen Interface is as follows:

Sponsor Type: [ ddlbSponsorType   ]

Event: [   TextBoxEvent   ]

Sponsor:  Company Id  : 

                Company Name  :  [  TextBoxCompanyName   ] [Look Up button]

                Contact Person Last Name  :  [  TextBoxPersonLastName  ]

                Contact Person First Name  :  [  TextBoxPersonFirstName   ]

                Contact Person Email  :  [  TextBoxPersonEmail ]

 

Company Id, Company Name, Contact Person fields are all embedded in a user control.  From Javascript, can you let me know how I can populate the company fields.  Using the document.getElementById seems to assign the correct values when I alert the values afte

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

MS SQL Server: Disconnect Users From Database - Kill User Session

  
If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

call JavaScript - jQuery code from ASP.NET Server-Side

  
jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side

Choosing Between a User Control or Web Part for SharePoint

  
SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Configuring User Profiles in SharePoint Server 2010

  
Note: I've added the necessary links relating to SharePoint Server 2010 prerequisites, along with instructions for configuring the user profile synchronization service, at the end of this

Sorting Data in a GridView Web Server Control

  
The GridView control provides built-in sorting functionality without requiring any coding. You can further customize the sort functionality of the GridView control by using custom SortExpression property values for columns as well as by using the Sorting and Sorted events

User Defined Functions in Microsoft SQL Server

  
User Defined Functions are compact pieces of Transact SQL code, which can accept parameters, and return either a value, or a table. They are saved as individual work units, and are created using standard SQL commands. Data transformation and reference value retrieval are common uses for functions. LEFT, the built in function for getting the left part of a string, and GETDATE, used for obtaining the current date and time, are two examples of function use. User Defined Functions enable the developer or DBA to create functions of their own, and save them inside SQL Server.

Server side validation of Fileupload control not working

  
 

 


I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.


Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
       

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
        Else
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2008

  

I am having problems with a user control. I want my solution to have a separate project for holding my user controls.


The main project can get a reference to this user control project and can import this user control dll into my main project. 


Thanks in advance,

Dheeraj Mittal

dhemittal@gmail.com


Multiple Instances of User Control

  

I have a user control that I place on a page severl times.  When I make a selection on a ddl in one one control the SelectedIndexChanged event fires for all the control on the page for that ddl.  So I get duplication of an insert that I do.  Is there a way to make sure these events are isolated so this doesn't happen.

Thanks,


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend