2013-03-28 6 views
1

Я зову простой метод javscript, и не знаю, почему эта ошибка происходитCS1061: «ASP.station_pages_stationfield_aspx» не содержит определение для «resizeIframe»

<iframe height="100px;" onload="resizeIframe(this)" runat="server" id="frameDayLeft" 
        scrolling="no" style="border: none; width: 250px" frameborder="0"></iframe> 

и вот ошибка деталь:

Compiler Error Message: CS1061: 'ASP.station_pages_stationfield_aspx' does not contain a definition for 'resizeIframe' and no extension method 'resizeIframe' accepting a first argument of type 'ASP.station_pages_stationfield_aspx' could be found (are you missing a using directive or an assembly reference?) 

ответ

2

Его должное к runat="server".

Невозможно найти функцию на стороне клиента [функция Javascript], но ее попытка найти ее на serveride [на .cs странице].

Именно поэтому ошибка возникает.

Попробуйте эту вещь в коде >>

frameDayLeft.Attributes.Add("onload", " resizeIframe(this)"); 

сделать как это >>

<script runat="server"> 
    void contentFrame_onLoadServer(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
      contentFrame.Attributes.Add("onLoad", "contentFrame_onLoadClient();"); 
    } 
</script> 
<script type="text/javascript"> 
    function contentFrame_onLoadClient() { 
     resizeFrame(document.getElementById('<%=contentFrame.ClientID %>')); 
    } 
    function resizeFrame(element) { 
     alert(element); // do your logic here 
    } 
</script> 
<iframe 
    runat="server" 
    id='contentFrame' 
    name='contentFrame' 
    width="500" 
    onload="contentFrame_onLoadServer" 
    /> 
+0

Спасибо, вы знаете, как я могу назвать javscript метод на OnLoad случае IFrame –

+0

frameDayLeft.Attributes .Add ("onload", "resizeIframe (this)"); – Freelancer

+0

@ VijaySinghRana пройти через отредактированный код – Freelancer

Смежные вопросы